Macro XAMINE (from Fraktal SAS Programming): Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K |
K |
||
Zeile 23: | Zeile 23: | ||
:%GLOBAL ne ie dir; | :%GLOBAL ne ie dir; | ||
</font> | </font> | ||
− | | | + | |Declare global macro variables for communication with called macros |
|- | |- | ||
| | | | ||
Zeile 29: | Zeile 29: | ||
:%LOCAL xpath xentry entry etype; | :%LOCAL xpath xentry entry etype; | ||
</font> | </font> | ||
− | | | + | |Declare local macro variables |
|- | |- | ||
| | | | ||
Zeile 35: | Zeile 35: | ||
;filename entries pipe "dir /b &XPATH." lrecl = 256; | ;filename entries pipe "dir /b &XPATH." lrecl = 256; | ||
</font> | </font> | ||
− | | | + | |Open access path to listing of OS directory content of type 'file' |
|- | |- | ||
| | | | ||
Zeile 41: | Zeile 41: | ||
;filename dirs pipe "dir /b /ad &XPATH." lrecl = 256; | ;filename dirs pipe "dir /b /ad &XPATH." lrecl = 256; | ||
</font> | </font> | ||
− | | | + | |Open access path to listing of OS directory content of type 'dir' |
|- | |- | ||
| | | | ||
Zeile 47: | Zeile 47: | ||
;data entries; | ;data entries; | ||
</font> | </font> | ||
− | | | + | |Initiate datastep to access OS directory content |
|- | |- | ||
| | | | ||
Zeile 53: | Zeile 53: | ||
:length entry $256; | :length entry $256; | ||
</font> | </font> | ||
− | | | + | |Declare length of data field 'entry' |
|- | |- | ||
| | | | ||
Zeile 59: | Zeile 59: | ||
:infile entries length = lrecl end = EOF; | :infile entries length = lrecl end = EOF; | ||
</font> | </font> | ||
− | | | + | |Set pointer to access path 'entries' |
|- | |- | ||
| | | | ||
Zeile 65: | Zeile 65: | ||
:input entry $varying256. lrecl; | :input entry $varying256. lrecl; | ||
</font> | </font> | ||
− | | | + | |Read from 'entries' with variable field length |
|- | |- | ||
| | | | ||
Zeile 71: | Zeile 71: | ||
:if EOF then call symput('ne',trim(left(put(_N_,8.)))); | :if EOF then call symput('ne',trim(left(put(_N_,8.)))); | ||
</font> | </font> | ||
− | | | + | |Write count of entries to macro variable 'ne' |
|- | |- | ||
| | | | ||
Zeile 77: | Zeile 77: | ||
;run; | ;run; | ||
</font> | </font> | ||
− | | | + | |Terminate datastep |
|- | |- | ||
| | | | ||
Zeile 83: | Zeile 83: | ||
;data dirs; | ;data dirs; | ||
</font> | </font> | ||
− | | | + | |Initiate datastep to access OS directories listing |
|- | |- | ||
| | | | ||
Zeile 89: | Zeile 89: | ||
:length dir $256; | :length dir $256; | ||
</font> | </font> | ||
− | | | + | |Declare length of data field 'dir' |
|- | |- | ||
| | | | ||
Zeile 95: | Zeile 95: | ||
:infile dirs length = lrecl end = EOF; | :infile dirs length = lrecl end = EOF; | ||
</font> | </font> | ||
− | | | + | |Set pointer to access path 'dirs' |
|- | |- | ||
| | | | ||
Zeile 101: | Zeile 101: | ||
:input dir $varying256. lrecl; | :input dir $varying256. lrecl; | ||
</font> | </font> | ||
− | | | + | |Read from 'dirs' with variable field length |
|- | |- | ||
| | | | ||
Zeile 107: | Zeile 107: | ||
;run; | ;run; | ||
</font> | </font> | ||
− | | | + | |Terminate datastep |
|- | |- | ||
| | | |
Version vom 29. Januar 2015, 18:31 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 datastep 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 datastep |
|
Initiate datastep 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 datastep |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
End Macro definition with name |