MACRO GET ATTR: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(Die Seite wurde neu angelegt: „Kategorie:zazy %MACRO GET_ATTR(dsn=,source=,attrib=) / store des = "Get attribute from SAS Variable"; %LOCAL name; %LET name = GET_ATTR; '''%IF &DSN…“) |
K |
||
(5 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
− | [[Kategorie:zazy]] | + | [[Kategorie:zazy]] |
+ | {{SeitenNavigation1 | ||
+ | |links=xx_left.png | ||
+ | |rechts=xx_right.png | ||
+ | |hoch=FRAKTAL_MACRO_ARCHITECTURE.png | ||
+ | |zurück=MACRO TWO BOBO | ||
+ | |vorwärts=MACRO GRP DESC | ||
+ | |übersicht=Info Modules (from Phase-III Macro System) | ||
+ | }} | ||
+ | |||
+ | [[Datei:FRAKTAL_MACRO_ARCHITECTURE.png|200px|thumb]] | ||
+ | |||
+ | == Type == | ||
+ | |||
+ | '''Info module''' from [[Phase-III Macro System]] based on '''''[[Fraktal SAS Programming|Fractal System Architecture]]'''''. | ||
+ | |||
+ | ==Source== | ||
%MACRO GET_ATTR(dsn=,source=,attrib=) / store des = "Get attribute from SAS Variable"; | %MACRO GET_ATTR(dsn=,source=,attrib=) / store des = "Get attribute from SAS Variable"; | ||
Zeile 5: | Zeile 21: | ||
%LOCAL name; | %LOCAL name; | ||
%LET name = GET_ATTR; | %LET name = GET_ATTR; | ||
− | '''%IF &DSN ne and &SOURCE ne and &ATTRIB ne %THEN %DO;''' | + | '''%IF &DSN. ne and &SOURCE. ne and &ATTRIB. ne %THEN %DO;''' |
− | '''%IF %INDEX(&DSN,.) eq 0 %THEN %DO;''' | + | '''%IF %INDEX(&DSN.,.) eq 0 %THEN %DO;''' |
− | %LET dsn=WORK.&DSN; | + | %LET dsn=WORK.&DSN.; |
'''%END;''' | '''%END;''' | ||
− | ''proc datasets nolist lib = %SCAN(&DSN,1);'' | + | ''proc datasets nolist lib = %SCAN(&DSN.,1);'' |
− | ''contents noprint data = %SCAN(&DSN,2)(keep=&SOURCE) out = work.tmp_data(keep=&ATTRIB);'' | + | ''contents noprint data = %SCAN(&DSN.,2)(keep=&SOURCE.) out = work.tmp_data(keep = &ATTRIB.);'' |
''run;'' | ''run;'' | ||
''quit;'' | ''quit;'' | ||
''proc sql noprint;'' | ''proc sql noprint;'' | ||
− | ''select &ATTRIB'' | + | ''select &ATTRIB.'' |
− | '' into :&ATTRIB'' | + | '' into :&ATTRIB.'' |
'' from work.tmp_data'' | '' from work.tmp_data'' | ||
'';'' | '';'' | ||
− | '''%IF %UPCASE(&ATTRIB) ne LABEL %THEN %DO;''' | + | '''%IF %UPCASE(&ATTRIB.) ne LABEL %THEN %DO;''' |
− | %LET &ATTRIB = &&&ATTRIB; | + | %LET &ATTRIB. = &&&ATTRIB.; |
'''%END;''' | '''%END;''' | ||
''quit;'' | ''quit;'' | ||
%PUT &NAME._MESSAGE: Temporary SAS dataset WORK.TMP_DATA created ; | %PUT &NAME._MESSAGE: Temporary SAS dataset WORK.TMP_DATA created ; | ||
− | %PUT &NAME._MESSAGE: Field %UPCASE(&SOURCE) in dataset %UPCASE(&DSN) has &ATTRIB = %BQUOTE(&&&ATTRIB.). ; | + | %PUT &NAME._MESSAGE: Field %UPCASE(&SOURCE.) in dataset %UPCASE(&DSN.) has &ATTRIB. = %BQUOTE(&&&ATTRIB.). ; |
%PUT &NAME._MESSAGE: Information stored into Local Macrovariable of calling environment: ; | %PUT &NAME._MESSAGE: Information stored into Local Macrovariable of calling environment: ; | ||
− | %PUT &NAME._MESSAGE: &ATTRIB=%BQUOTE(&&&ATTRIB); | + | %PUT &NAME._MESSAGE: &ATTRIB. = %BQUOTE(&&&ATTRIB.); |
%PUT ; | %PUT ; | ||
'''%END;''' | '''%END;''' | ||
Zeile 34: | Zeile 50: | ||
%PUT &NAME._STATUS: Global Macrovariable(s) not available. ; | %PUT &NAME._STATUS: Global Macrovariable(s) not available. ; | ||
%PUT ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^; | %PUT ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^; | ||
− | %GEN_MAIL(name=&NAME,rc=1); | + | %GEN_MAIL(name = &NAME.,rc = 1); |
'''%END;''' | '''%END;''' | ||
%MEND GET_ATTR; | %MEND GET_ATTR; |
Aktuelle Version vom 5. März 2014, 21:03 Uhr
Type
Info module from Phase-III Macro System based on Fractal System Architecture.
Source
%MACRO GET_ATTR(dsn=,source=,attrib=) / store des = "Get attribute from SAS Variable";
%LOCAL name; %LET name = GET_ATTR; %IF &DSN. ne and &SOURCE. ne and &ATTRIB. ne %THEN %DO; %IF %INDEX(&DSN.,.) eq 0 %THEN %DO; %LET dsn=WORK.&DSN.; %END; proc datasets nolist lib = %SCAN(&DSN.,1); contents noprint data = %SCAN(&DSN.,2)(keep=&SOURCE.) out = work.tmp_data(keep = &ATTRIB.); run; quit; proc sql noprint; select &ATTRIB. into :&ATTRIB. from work.tmp_data ; %IF %UPCASE(&ATTRIB.) ne LABEL %THEN %DO; %LET &ATTRIB. = &&&ATTRIB.; %END; quit; %PUT &NAME._MESSAGE: Temporary SAS dataset WORK.TMP_DATA created ; %PUT &NAME._MESSAGE: Field %UPCASE(&SOURCE.) in dataset %UPCASE(&DSN.) has &ATTRIB. = %BQUOTE(&&&ATTRIB.). ; %PUT &NAME._MESSAGE: Information stored into Local Macrovariable of calling environment: ; %PUT &NAME._MESSAGE: &ATTRIB. = %BQUOTE(&&&ATTRIB.); %PUT ; %END; %ELSE %DO; %PUT vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv; %PUT &NAME._ERROR: Missing Keyword Parameter(s).; %PUT &NAME._STATUS: Macro processing abended. ; %PUT &NAME._STATUS: Global Macrovariable(s) not available. ; %PUT ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^; %GEN_MAIL(name = &NAME.,rc = 1); %END;
%MEND GET_ATTR;