Macro XSET (from Fraktal SAS Programming): Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K |
K |
||
Zeile 15: | Zeile 15: | ||
| | | | ||
;%MACRO xset(xvar); | ;%MACRO xset(xvar); | ||
− | |Start Macro definition with name and positional parameter 'xvar' | + | |Start Macro definition with name and positional parameter ''xvar'' |
|- | |- | ||
| | | | ||
:filename path pipe "set" lrecl = 2048; | :filename path pipe "set" lrecl = 2048; | ||
− | | | + | |Open source for text data of type ''pipe'' pointing to OS command |
|- | |- | ||
| | | | ||
;data _NULL_; | ;data _NULL_; | ||
− | | | + | |Start datastep run group |
|- | |- | ||
| | | | ||
:length xvar $256 xval $1024; | :length xvar $256 xval $1024; | ||
− | | | + | |Declare variables ''xvar'' and ''xval'' by length in bytes |
|- | |- | ||
| | | | ||
:infile path dlm = '='; | :infile path dlm = '='; | ||
− | | | + | |Utilize data stream from data source ''path'' |
|- | |- | ||
| | | | ||
:input xvar $ xval $; | :input xvar $ xval $; | ||
− | | | + | |Define structure od data stream ''path'' with variables xvar and xval |
|- | |- | ||
| | | | ||
:xvar = upcase(translate(xvar,'_','(-)')); | :xvar = upcase(translate(xvar,'_','(-)')); | ||
− | | | + | |Remove unwanted characters from variable ''xvar'' |
|- | |- | ||
| | | | ||
;%IF %LENGTH(&XVAR.) <> 0 %THEN %DO; | ;%IF %LENGTH(&XVAR.) <> 0 %THEN %DO; | ||
− | | | + | |Specify condition on macro parameter ''xvar'' for using code segment |
|- | |- | ||
| | | | ||
:if trim(xvar) = "%UPCASE(&XVAR.)"; | :if trim(xvar) = "%UPCASE(&XVAR.)"; | ||
− | | | + | |Conditionally executed code |
|- | |- | ||
| | | | ||
;%END; | ;%END; | ||
− | | | + | |End condition on macro parameter ''xvar'' |
|- | |- | ||
| | | | ||
:call symput(compress(xvar),compress(xval)); | :call symput(compress(xvar),compress(xval)); | ||
− | | | + | |Transfer variable values to symbol table |
|- | |- | ||
| | | | ||
;run; | ;run; | ||
− | | | + | |End data step run group |
|- | |- | ||
| | | | ||
:filename path clear; | :filename path clear; | ||
− | | | + | |Close source for text data |
|- | |- | ||
| | | |
Version vom 29. Juli 2014, 16:50 Uhr
Code executed | Function performed |
---|---|
|
Start Macro definition with name and positional parameter xvar |
|
Open source for text data of type pipe pointing to OS command |
|
Start datastep run group |
|
Declare variables xvar and xval by length in bytes |
|
Utilize data stream from data source path |
|
Define structure od data stream path with variables xvar and xval |
|
Remove unwanted characters from variable xvar |
|
Specify condition on macro parameter xvar for using code segment |
|
Conditionally executed code |
|
End condition on macro parameter xvar |
|
Transfer variable values to symbol table |
|
End data step run group |
|
Close source for text data |
|
End Macro definition with name |