Loop over names in SAS-IML? -
how can read sas-dataset name given stem+suffix iml? stem given sas macro variable, suffices intend use in string-vector in iml.
in r use
suffix<-c('s1','s2') (s in suffix){ data<-eval(as.name(paste(stem,s,sep=''))) }
i looping if had code first dataset. tried:
proc iml; suffices = {'s1','s2'}; call symput('suffix',suffices[1]); use &stem.&suffix.;
the problem being if in do-loop (and need loop on names), call symput not work. here found symget, in context of use &stem.symget('suffix') not fruitful.
any other ideas?
edit: found following rather inelegant solution:
proc iml; %global suff; suffix={'s1','s2','s3'}; %do ii = 1 %to 3; call symput('suff',suffix[&ii.]); <do stuff based on suffix> %end;
still not feel way 1 supposed work on it.
the easiest way can think of use non-iml syntax. proc sql example can generate macro variable lists.
%let stem=class_; data class_s1 class_s2; set sashelp.class; run; data suffices; input suffix $; datalines; s1 s2 ;;;; run; %macro use_suffix(suffix=); use &stem.&suffix.; read &stem.&suffix.; print &stem.&suffix.; %mend use_suffix; proc sql; select cats('%use_suffix(suffix=',suffix,')') :suffixlist separated ' ' suffices; quit; proc iml; &suffixlist; quit;
Comments
Post a Comment