forked from IU-Data-Management/SAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenExcel.sas
More file actions
49 lines (38 loc) · 995 Bytes
/
Copy pathOpenExcel.sas
File metadata and controls
49 lines (38 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
Name: OpenExcel
Description: Opens a new Excel Session if an existing session
is not already open.
Type: Excel Interface
Arguments: <none>
Other Inputs: <none>
Output: <none>
Usage Notes: <none>
Calls macros: <none>
History: Date Init Comments
10/8/2008 MAS Creation
*/
%macro OpenExcel;
/*Opens a new excel session if an existing session is not
already open*/
options noxwait noxsync;
filename control dde "Excel|system";
data _null_;
length fid rc start stop time 8;
/*test to see if excel is already open*/
fid=fopen("control",'s');
/*If it's not, open excel*/
if (fid le 0) then do;
rc=system('start excel');
/*Stop waiting once excel opens and give it only
10 second so no infinite loops result*/
start=datetime();
stop=start+10;
do while (fid le 0);
fid=fopen("control",'s');
time=datetime();
if (time ge stop) then fid=1;
end;
end;
rc=fclose(fid);
run;
%mend OpenExcel;