Process Metadata: Numbered (from Fraktal SAS Programming): Unterschied zwischen den Versionen

Aus phenixxenia.org
Zur Navigation springen Zur Suche springen
(Die Seite wurde neu angelegt: „== Generate == The numbered approach starts by storing the unique values in an intermediate table. The lines of this table are then assigned with the '''''SYM…“)
 
K
 
Zeile 1: Zeile 1:
 +
[[Kategorie:zazy]]
 +
{{SeitenNavigation1
 +
|links=xx_left.png
 +
|zurück=Process Metadata: List (from Fraktal SAS Programming)
 +
|rechts=xx_right.png
 +
|vorwärts=Process Metadata: Direct (from Fraktal SAS Programming)
 +
|hoch=Duck_zazy_com.png
 +
|übersicht=Process Metadata (from Fraktal SAS Programming)
 +
}}
 +
 
== Generate ==
 
== Generate ==
  
Zeile 54: Zeile 64:
 
  ''run;''
 
  ''run;''
 
  '''%END;'''
 
  '''%END;'''
 +
 +
{{SeitenNavigation1
 +
|links=xx_left.png
 +
|zurück=Process Metadata: List (from Fraktal SAS Programming)
 +
|rechts=xx_right.png
 +
|vorwärts=Process Metadata: Direct (from Fraktal SAS Programming)
 +
|hoch=Duck_zazy_com.png
 +
|übersicht=Process Metadata (from Fraktal SAS Programming)
 +
}}

Aktuelle Version vom 30. Januar 2014, 10:52 Uhr

Zurück

Übersicht

Vorwärts

Generate

The numbered approach starts by storing the unique values in an intermediate table. The lines of this table are then assigned with the SYMPUT call routine to numbered MACRO variables using the record number read from the automatic data step variable "_N_".

/*
generate the list itself
*/
proc sql noprint;
create table age_list as
select distinct age
  from sashelp.class
;
quit; 
data _null_;
 set age_list;
call symput("age_grp"||left(put(_N_,8.)),trim(left(put(age,8.))));
run;


Count

There is probably no less elegant way to determine the number of values but we will use it here for demonstration purposes.

Nevertheless, this method is definitely indicated when all lines read are used as does the code presented in step 2 before.

/*
obtain the number of elements
*/
data _null_;
 set age_list end = eof;
if eof then do;
call symput("age_grps",trim(left(put(_N_,8.))));
end; 
run;


Utilize

First, utilization seems pretty similar to the list approach, since the DO loop remains unchanged. However, the re-construction of parameter names from the loop variable AGE_INDX requires multiple ampersands.

The most simple, and yet correct, explanation says, that the ampersand is parameter name and value as well, i.e. the MACRO variable with name "&" resolves to "&.

Thus, the double ampersand use "&&" produces all required parameter references starting with AGE_GRP1.

/*
utilize list elements 
*/
%DO age_indx = 1 %TO &AGE_GRPS.;
proc print noobs 
     data = sashelp.class
;
where age = &&AGE_GRP&AGE_INDX.;
run;
%END;

Zurück

Übersicht

Vorwärts