SASUnit Examples  Version 1.5.0
windows/_xcmd.sas
Go to the documentation of this file.
1 
21 %MACRO _xcmd(i_cmd);
22 
23  %LOCAL xwait xsync xmin logfile;
24  %LET xwait=%sysfunc(getoption(xwait));
25  %LET xsync=%sysfunc(getoption(xsync));
26  %LET xmin =%sysfunc(getoption(xmin));
27 
28  OPTIONS noxwait xsync xmin;
29 
30  %LET logfile=%sysfunc(pathname(work))\___log.txt;
31 
32  %SYSEXEC &i_cmd > "&logfile";
33 
34 
35  %IF &g_verbose. %THEN %DO;
36  %PUT ======== OS Command Start ========;
37  /* Evaluate sysexec´s return code*/
38  %IF &sysrc. = 0 %THEN %PUT &g_note.(SASUNIT): Sysrc : 0 -> SYSEXEC SUCCESSFUL;
39  %ELSE %PUT &g_error.(SASUNIT): Sysrc : &sysrc -> An Error occured;
40 
41  /* put sysexec command to log*/
42  %PUT &g_note.(SASUNIT): SYSEXEC COMMAND IS: &i_cmd > "&logfile";
43 
44  /* write &logfile to the log*/
45  DATA _NULL_;
46  infile "&logfile" truncover;
47  input;
48  putlog _infile_;
49  RUN;
50 
51  %PUT ======== OS Command End ========;
52  %END;
53 
54  OPTIONS &xwait &xsync &xmin;
55 
56 %MEND _xcmd;
57