SASUnit Examples  Version 1.5.0
windows/_oscmds.sas
Go to the documentation of this file.
1 
19 %macro _oscmds;
20 
21  %global
22  g_copydir
23  g_endcommand
24  g_makedir
25  g_removedir
26  g_removefile
27  g_sasstart
28  g_splash
29  g_dateformat
30  ;
31 
32  %local
33  l_filename
34  ;
35 
36  %LET g_copydir = xcopy /E /I /Y;
37  %LET g_endcommand =%str( );
38  %LET g_makedir = md;
39  %LET g_removedir = rd /S /Q;
40  %LET g_removefile = del /S /Q;
41  %LET g_sasstart ="%sysget(sasroot)/sas.exe";
42  %LET g_splash = -nosplash;
43 
44  * retrieve dateformat from WINDOWS registry *;
45  * Set default if anything goes wrong *;
46  %LET g_dateformat = _NONE_;
47 
48  %let xwait=%sysfunc(getoption(xwait));
49  %let xsync=%sysfunc(getoption(xsync));
50  %let xmin =%sysfunc(getoption(xmin));
51 
52  options noxwait xsync xmin;
53 
54  %let l_filename = %sysfunc (pathname (work))\retrive_dateformat.txt;
55  %sysexec (reg query "HKCU\Control Panel\International" /v sShortDate > "&l_filename.");
56 
57  options &xwait &xsync &xmin;
58 
59  data _null_;
60  length g_dateformat $40;
61  infile "&l_filename.";
62  input;
63  if index (upcase (_INFILE_), "REG_SZ") then do;
64  dateformat = lowcase (scan (_INFILE_,3," "));
65  * Building SAS-format name from WIN-Dateformat *;
66  * Set default for dateformat *;
67  g_dateformat = "nldate.";
68  * Check if monthname is displayed *;
69  if (index (dateformat,"mmm")=0) then do;
70  * Check order of day month year *;
71  index_d=index (dateformat,"d");
72  index_m=index (dateformat,"m");
73  index_y=index (dateformat,"y");
74  if (index_y < index_m) then do;
75  if (index_d < index_m) then do;
76  g_dateformat = "yyddmm10.";
77  end;
78  else do;
79  g_dateformat = "yymmdd10.";
80  end;
81  end;
82  else do;
83  if (index_d > index_m) then do;
84  g_dateformat = "mmddyy10.";
85  end;
86  else do;
87  g_dateformat = "ddmmyy10.";
88  end;
89  end;
90  end;
91  call symputx ("G_DATEFORMAT", trim (g_dateformat));
92  end;
93  run;
94 %mend _oscmds;
95