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

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

Version vom 4. September 2014, 16:38 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