Macro XDIR (from Fraktal SAS Programming): Unterschied zwischen den Versionen
		
		
		
		Zur Navigation springen
		Zur Suche springen
		
| KKeine Bearbeitungszusammenfassung | KKeine Bearbeitungszusammenfassung | ||
| Zeile 17: | Zeile 17: | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| ;%MACRO xdir(xpath); | ;%MACRO xdir(xpath); | ||
| </font>  | |||
| |Start macro definition with name and positional parameter ''xpath''. | |Start macro definition with name and positional parameter ''xpath''. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| ;%IF %LENGTH(&XPATH.) = 0 %THEN %DO; | ;%IF %LENGTH(&XPATH.) = 0 %THEN %DO; | ||
| </font>  | |||
| |Define branch when parameter ''xpath'' is not supplied. | |Define branch when parameter ''xpath'' is not supplied. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| ;%WINDOW path   | ;%WINDOW path   | ||
| </font>  | |||
| |Start definition of pop-up window. | |Start definition of pop-up window. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| : irow = 20 rows = 14 icolumn = 30 columns = 64          | : irow = 20 rows = 14 icolumn = 30 columns = 64          | ||
| </font>  | |||
| |Specify position and size of window. | |Specify position and size of window. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| : #4 @5 'Enter path: ' xpath 40 attr = underline                  | : #4 @5 'Enter path: ' xpath 40 attr = underline                  | ||
| </font>  | |||
| |Specify constant text shown, parameter name to be populated and attributes. | |Specify constant text shown, parameter name to be populated and attributes. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| ; ; | ; ; | ||
| </font>  | |||
| |Terminate pop-up window definition statement. | |Terminate pop-up window definition statement. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| :%DISPLAY path; | :%DISPLAY path; | ||
| </font>  | |||
| |Open pop-up window. | |Open pop-up window. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| ;%END; | ;%END; | ||
| </font>  | |||
| |Finalize branch definition for empty parameter ''xpath''. | |Finalize branch definition for empty parameter ''xpath''. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| ;filename path pipe "dir /b ""&XPATH.""" lrecl = 256; | ;filename path pipe "dir /b ""&XPATH.""" lrecl = 256; | ||
| </font>  | |||
| |Define text data stream with type '''''pipe''''' and logical record length. | |Define text data stream with type '''''pipe''''' and logical record length. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| ;data _NULL_; | ;data _NULL_; | ||
| </font>  | |||
| |Initiate data step run group. | |Initiate data step run group. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| :length entry $256; | :length entry $256; | ||
| </font>  | |||
| |Specify length in byte for character field ''entry''. | |Specify length in byte for character field ''entry''. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| :infile path length = lrecl; | :infile path length = lrecl; | ||
| </font>  | |||
| |Open text data stream ''path''. | |Open text data stream ''path''. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| :input entry $varying256. lrecl; | :input entry $varying256. lrecl; | ||
| </font>  | |||
| |Specify structure of data stream ''path''. | |Specify structure of data stream ''path''. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| :  put entry;   | :  put entry;   | ||
| </font>  | |||
| |Write value from field ''entry'' to the SAS LOG screen. | |Write value from field ''entry'' to the SAS LOG screen. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| ;run; | ;run; | ||
| </font>  | |||
| |Terminate data step run group. | |Terminate data step run group. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| ;filename path clear; | ;filename path clear; | ||
| </font>  | |||
| |Revoke definition of text data stream. | |Revoke definition of text data stream. | ||
| |- | |- | ||
| | | | | ||
| <font face="Courier New">  | |||
| ;%MEND xdir; | ;%MEND xdir; | ||
| </font>  | |||
| |END macro definition with name | |END macro definition with name | ||
| |} | |} | ||
Version vom 7. August 2014, 08:48 Uhr
This SAS Macro reads entries from a specified OS directory and writes results to the SAS LOG screen.
- When no directory is specified, a pop-up window is defined and opened to ask the user for the directory name.
| Code executed | Function performed | 
|---|---|
| 
 
 
 | Start macro definition with name and positional parameter xpath. | 
| 
 
 
 | Define branch when parameter xpath is not supplied. | 
| 
 
 
 | Start definition of pop-up window. | 
| 
 
 
 | Specify position and size of window. | 
| 
 
 
 | Specify constant text shown, parameter name to be populated and attributes. | 
| 
 
 
 | Terminate pop-up window definition statement. | 
| 
 
 
 | Open pop-up window. | 
| 
 
 
 | Finalize branch definition for empty parameter xpath. | 
| 
 
 
 | Define text data stream with type pipe and logical record length. | 
| 
 
 
 | Initiate data step run group. | 
| 
 
 
 | Specify length in byte for character field entry. | 
| 
 
 
 | Open text data stream path. | 
| 
 
 
 | Specify structure of data stream path. | 
| 
 
 
 | Write value from field entry to the SAS LOG screen. | 
| 
 
 
 | Terminate data step run group. | 
| 
 
 
 | Revoke definition of text data stream. | 
| 
 
 
 | END macro definition with name | 


