Macro XAMINE (from Fraktal SAS Programming): Unterschied zwischen den Versionen

Aus phenixxenia.org
Zur Navigation springen Zur Suche springen
K
K
Zeile 9: Zeile 9:
 
}}
 
}}
  
%MACRO xamine(xpath,etype);
+
{| class="wikitable"
%GLOBAL ne ie dir;
+
! Code executed
%LOCAL xpath xentry entry etype;
+
! Function performed
filename entries pipe "dir /b &XPATH." lrecl = 256;
+
|-
filename dirs pipe "dir /b /ad &XPATH." lrecl = 256;  
+
|
data entries;
+
%MACRO xamine(xpath,etype);
length entry $256;
+
|
infile entries length = lrecl end = EOF;
+
|-
input entry $varying256. lrecl;
+
|
if EOF then call symput('ne',trim(left(put(_N_,8.))));
+
:%GLOBAL ne ie dir;
run;
+
|
data dirs;
+
|-
length dir $256;
+
|
infile dirs length = lrecl end = EOF;
+
:%LOCAL xpath xentry entry etype;
input dir $varying256. lrecl;
+
|
run;
+
|-
%DO ie = 1 %TO &NE.;
+
|
data _NULL_;
+
;filename entries pipe "dir /b &XPATH." lrecl = 256;
set entries(firstobs = &IE. obs = &IE.);
+
|
call symput('entry',compress(translate(entry,'_','(-)')));
+
|-
call symput('xentry',trim(left(entry)));
+
|
run;
+
;filename dirs pipe "dir /b /ad &XPATH." lrecl = 256;  
%PUT |;
+
|
%PUT &XPATH.&XENTRY.;
+
|-
data _NULL_;
+
|
  set dirs(where = (dir = "&XENTRY.")) end = EOF;
+
;data entries;
if EOF then call symput('dir',trim(left(put(_N_,8.))));
+
|
run;
+
|-
%IF &DIR. = 1 %THEN %DO;
+
|
%PUT +----;
+
:length entry $256;
%XDIR(&XPATH.&XENTRY.);
+
|
%PUT +----;
+
|-
%END;
+
|
%ELSE %DO;
+
:infile entries length = lrecl end = EOF;
%IF %LENGTH(&ETYPE.) ne 0 %THEN %DO;
+
|
%IF %INDEX(%SCAN(&ETYPE.,2,_),%SCAN(&XENTRY,2,.)) != 0 %THEN %DO;
+
|-
%GLOBAL windir;
+
|
%XSET(windir);
+
:input entry $varying256. lrecl;
%PUT +----;
+
|
%PUT | File &XENTRY. opened in external editor WordPad.;
+
|-
SYSTASK command "&WINDIR.\write.exe ""&XPATH.\&XENTRY.""";
+
|
%PUT +----;
+
:if EOF then call symput('ne',trim(left(put(_N_,8.))));
%END;
+
|
%IF %INDEX(%SCAN(&ETYPE.,1,_),%SCAN(&XENTRY,2,.)) != 0 %THEN %DO;
+
|-
%PUT +----;
+
|
%PUT | File &XENTRY. opened in SAS program editor window.;
+
;run;
%XEDIT(&XENTRY.,&XPATH.);
+
|
%PUT +----;
+
|-
%END;
+
|
%END;
+
;data dirs;
%END;
+
|
%LET dir =;
+
|-
%END;
+
|
proc sql;
+
:length dir $256;
drop table dirs;
+
|
drop table entries;
+
|-
quit;
+
|
filename entries clear;
+
:infile dirs length = lrecl end = EOF;
filename dirs clear;
+
|
%MEND xamine;
+
|-
 +
|
 +
:input dir $varying256. lrecl;
 +
|
 +
|-
 +
|
 +
;run;
 +
|
 +
|-
 +
|
 +
;%DO ie = 1 %TO &NE.;
 +
|
 +
|-
 +
|
 +
;data _NULL_;
 +
|
 +
|-
 +
|
 +
:set entries(firstobs = &IE. obs = &IE.);
 +
|
 +
|-
 +
|
 +
:call symput('entry',compress(translate(entry,'_','(-)')));
 +
|
 +
|-
 +
|
 +
:call symput('xentry',trim(left(entry)));
 +
|
 +
|-
 +
|
 +
;run;
 +
|
 +
|-
 +
|
 +
:%PUT |;
 +
|
 +
|-
 +
|
 +
:%PUT &XPATH.&XENTRY.;
 +
|
 +
|-
 +
|
 +
:%LET dir =;
 +
|
 +
|-
 +
|
 +
;data _NULL_;
 +
|
 +
|-
 +
|
 +
: set dirs(where = (dir = "&XENTRY.")) end = EOF;
 +
|
 +
|-
 +
|
 +
:if EOF then call symput('dir',trim(left(put(_N_,8.))));
 +
|
 +
|-
 +
|
 +
;run;
 +
|
 +
|-
 +
|
 +
;%IF &DIR. = 1 %THEN %DO;
 +
|
 +
|-
 +
|
 +
:%PUT +----;
 +
|
 +
|-
 +
|
 +
:%XDIR(&XPATH.&XENTRY.);
 +
|
 +
|-
 +
|
 +
:%PUT +----;
 +
|
 +
|-
 +
|
 +
;%END;
 +
|
 +
|-
 +
|
 +
;%ELSE %DO;
 +
|
 +
|-
 +
|
 +
;%IF %LENGTH(&ETYPE.) ne 0 %THEN %DO;
 +
|
 +
|-
 +
|
 +
;%IF %INDEX(%SCAN(&ETYPE.,2,_),%SCAN(&XENTRY,2,.)) != 0 %THEN %DO;
 +
|
 +
|-
 +
|
 +
:%GLOBAL windir;
 +
|
 +
|-
 +
|
 +
:%XSET(windir);
 +
|
 +
|-
 +
|
 +
:%PUT +----;
 +
|
 +
|-
 +
|
 +
:%PUT | File &XENTRY. opened in external editor WordPad.;
 +
|
 +
|-
 +
|
 +
:SYSTASK command "&WINDIR.\write.exe ""&XPATH.\&XENTRY.""";
 +
|
 +
|-
 +
|
 +
:%PUT +----;
 +
|
 +
|-
 +
|
 +
;%END;
 +
|
 +
|-
 +
|
 +
;%IF %INDEX(%SCAN(&ETYPE.,1,_),%SCAN(&XENTRY,2,.)) != 0 %THEN %DO;
 +
|
 +
|-
 +
|
 +
:%PUT +----;
 +
|
 +
|-
 +
|
 +
:%PUT | File &XENTRY. opened in SAS program editor window.;
 +
|
 +
|-
 +
|
 +
:%XEDIT(&XENTRY.,&XPATH.);
 +
|
 +
|-
 +
|
 +
:%PUT +----;
 +
|
 +
|-
 +
|
 +
;%END;
 +
|
 +
|-
 +
|
 +
;%END;
 +
|
 +
|-
 +
|
 +
;%END;
 +
|
 +
|-
 +
|
 +
;%END;
 +
|
 +
|-
 +
|
 +
;proc sql;
 +
|
 +
|-
 +
|
 +
:drop table dirs;
 +
|
 +
|-
 +
|
 +
:drop table entries;
 +
|
 +
|-
 +
|
 +
;quit;
 +
|
 +
|-
 +
|
 +
;filename entries clear;
 +
|
 +
|-
 +
|
 +
;filename dirs clear;
 +
|
 +
|-
 +
|
 +
;%MEND xamine;
 +
|
 +
|}
  
 
{{SeitenNavigation1
 
{{SeitenNavigation1

Version vom 31. Juli 2014, 15:36 Uhr

Zurück

Übersicht

Vorwärts

Code executed Function performed

%MACRO xamine(xpath,etype);

%GLOBAL ne ie dir;
%LOCAL xpath xentry entry etype;
filename entries pipe "dir /b &XPATH." lrecl = 256;
filename dirs pipe "dir /b /ad &XPATH." lrecl = 256;
data entries;
length entry $256;
infile entries length = lrecl end = EOF;
input entry $varying256. lrecl;
if EOF then call symput('ne',trim(left(put(_N_,8.))));
run;
data dirs;
length dir $256;
infile dirs length = lrecl end = EOF;
input dir $varying256. lrecl;
run;
%DO ie = 1 %TO &NE.;
data _NULL_;
set entries(firstobs = &IE. obs = &IE.);
call symput('entry',compress(translate(entry,'_','(-)')));
call symput('xentry',trim(left(entry)));
run;
%PUT |;
%PUT &XPATH.&XENTRY.;
%LET dir =;
data _NULL_;
set dirs(where = (dir = "&XENTRY.")) end = EOF;
if EOF then call symput('dir',trim(left(put(_N_,8.))));
run;
%IF &DIR. = 1 %THEN %DO;
%PUT +----;
%XDIR(&XPATH.&XENTRY.);
%PUT +----;
%END;
%ELSE %DO;
%IF %LENGTH(&ETYPE.) ne 0 %THEN %DO;
%IF %INDEX(%SCAN(&ETYPE.,2,_),%SCAN(&XENTRY,2,.)) != 0 %THEN %DO;
%GLOBAL windir;
%XSET(windir);
%PUT +----;
%PUT | File &XENTRY. opened in external editor WordPad.;
SYSTASK command "&WINDIR.\write.exe ""&XPATH.\&XENTRY.""";
%PUT +----;
%END;
%IF %INDEX(%SCAN(&ETYPE.,1,_),%SCAN(&XENTRY,2,.)) != 0 %THEN %DO;
%PUT +----;
%PUT | File &XENTRY. opened in SAS program editor window.;
%XEDIT(&XENTRY.,&XPATH.);
%PUT +----;
%END;
%END;
%END;
%END;
proc sql;
drop table dirs;
drop table entries;
quit;
filename entries clear;
filename dirs clear;
%MEND xamine;

Zurück

Übersicht

Vorwärts