Macro XAMINE (from Fraktal SAS Programming): Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K |
K |
||
Zeile 47: | Zeile 47: | ||
;data entries; | ;data entries; | ||
</font> | </font> | ||
− | |Initiate | + | |Initiate data step to access OS directory content |
|- | |- | ||
| | | | ||
Zeile 77: | Zeile 77: | ||
;run; | ;run; | ||
</font> | </font> | ||
− | |Terminate | + | |Terminate data step |
|- | |- | ||
| | | | ||
Zeile 83: | Zeile 83: | ||
;data dirs; | ;data dirs; | ||
</font> | </font> | ||
− | |Initiate | + | |Initiate data step to access OS directories listing |
|- | |- | ||
| | | | ||
Zeile 107: | Zeile 107: | ||
;run; | ;run; | ||
</font> | </font> | ||
− | |Terminate | + | |Terminate data step |
|- | |- | ||
| | | | ||
Zeile 113: | Zeile 113: | ||
;%DO ie = 1 %TO &NE.; | ;%DO ie = 1 %TO &NE.; | ||
</font> | </font> | ||
− | | | + | |Start macro loop to process entries one by one with loop index 'ie' |
|- | |- | ||
| | | | ||
Zeile 119: | Zeile 119: | ||
;data _NULL_; | ;data _NULL_; | ||
</font> | </font> | ||
− | | | + | |Initiate data step without creating a dataset |
|- | |- | ||
| | | | ||
Zeile 125: | Zeile 125: | ||
:set entries(firstobs = &IE. obs = &IE.); | :set entries(firstobs = &IE. obs = &IE.); | ||
</font> | </font> | ||
− | | | + | |Read row number 'ie' from dataset 'entries' |
|- | |- | ||
| | | | ||
Zeile 131: | Zeile 131: | ||
:call symput('entry',compress(translate(entry,'_','(-)'))); | :call symput('entry',compress(translate(entry,'_','(-)'))); | ||
</font> | </font> | ||
− | | | + | |Write value from read row to macro variable 'entry' with intermediate name processing |
|- | |- | ||
| | | | ||
Zeile 137: | Zeile 137: | ||
:call symput('xentry',trim(left(entry))); | :call symput('xentry',trim(left(entry))); | ||
</font> | </font> | ||
− | | | + | |Write value from read row to macro variable 'xentry' |
|- | |- | ||
| | | | ||
Zeile 143: | Zeile 143: | ||
;run; | ;run; | ||
</font> | </font> | ||
− | | | + | |Terminate data step |
|- | |- | ||
| | | | ||
Zeile 149: | Zeile 149: | ||
:%PUT |; | :%PUT |; | ||
</font> | </font> | ||
− | | | + | |Write string '|' to the LOG |
|- | |- | ||
| | | | ||
Zeile 155: | Zeile 155: | ||
:%PUT &XPATH.&XENTRY.; | :%PUT &XPATH.&XENTRY.; | ||
</font> | </font> | ||
− | | | + | |Write full path and filename to the LOG |
|- | |- | ||
| | | | ||
Zeile 161: | Zeile 161: | ||
:%LET dir =; | :%LET dir =; | ||
</font> | </font> | ||
− | | | + | |Reset value for macro variable 'dir' |
|- | |- | ||
| | | | ||
Zeile 167: | Zeile 167: | ||
;data _NULL_; | ;data _NULL_; | ||
</font> | </font> | ||
− | | | + | |Initiate data step without creating a dataset |
|- | |- | ||
| | | | ||
Zeile 173: | Zeile 173: | ||
: set dirs(where = (dir = "&XENTRY.")) end = EOF; | : set dirs(where = (dir = "&XENTRY.")) end = EOF; | ||
</font> | </font> | ||
− | | | + | |Read value from dataset 'dirs' for |
|- | |- | ||
| | | |
Version vom 29. Januar 2015, 19:26 Uhr
Code executed | Function performed |
---|---|
|
Start Macro definition with name and positional parameters xpath and etype |
|
Declare global macro variables for communication with called macros |
|
Declare local macro variables |
|
Open access path to listing of OS directory content of type 'file' |
|
Open access path to listing of OS directory content of type 'dir' |
|
Initiate data step to access OS directory content |
|
Declare length of data field 'entry' |
|
Set pointer to access path 'entries' |
|
Read from 'entries' with variable field length |
|
Write count of entries to macro variable 'ne' |
|
Terminate data step |
|
Initiate data step to access OS directories listing |
|
Declare length of data field 'dir' |
|
Set pointer to access path 'dirs' |
|
Read from 'dirs' with variable field length |
|
Terminate data step |
|
Start macro loop to process entries one by one with loop index 'ie' |
|
Initiate data step without creating a dataset |
|
Read row number 'ie' from dataset 'entries' |
|
Write value from read row to macro variable 'entry' with intermediate name processing |
|
Write value from read row to macro variable 'xentry' |
|
Terminate data step |
|
' to the LOG |
|
Write full path and filename to the LOG |
|
Reset value for macro variable 'dir' |
|
Initiate data step without creating a dataset |
|
Read value from dataset 'dirs' for |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
End Macro definition with name |