|
satya,
Okay here ya go it works for me th edesign sucks but I am running short on
time so I will let you play with that:
%let varlist = c_d_sex c_d_wei1 c_d_wei2 c_d_age1 c_d_age2 c_d_age3 ;
%let varpart = c_d_wei1 c_d_wei2 ;
%macro redolist ;
%local stop I to from ;
%let stop = %eval(%sysfunc(countc(&varlist,' ')) + 1) ;
%do I = 1 %to &stop ;
%if ( %index(&varpart,%scan(&varlist , &i , ' ')) = 0 ) %then %do ;
%let to = b_%substr(%scan(&varlist , &i , ' '),3) ;
%let from = %scan(&varlist , &i , ' ') ;
%let varlist = %sysfunc(tranwrd(&varlist,&from,&to)) ;
%end ;
%end ;
%mend redolist ;
%redolist
%put &Varlist ;
Toby Dunn
From: satya <satyaanam@HOTMAIL.COM>
Reply-To: satya <satyaanam@HOTMAIL.COM>
To: SAS-L@LISTSERV.UGA.EDU
Subject: complement of a macro variable
Date: Tue, 1 Nov 2005 19:08:24 -0800
dear sas-lers,
here is my problem for today.
i have a macro variable that list some variables:
%let varlist=c_d_sex c_d_wei1 c_d_wei2 c_d_age1 c_d_age2 c_d_age3;
and a corresponding macroavr that list a part of it, say;
%let varpart=c_d_wei1 c_d_wei2;
i want to create a third macrovar, corresponding to varlist, in which
each single string of the complement to varpart has a different prefix
(b instead of c) that is:
varlist1=b_d_sex c_d_wei1 c_d_wei2 b_d_age1 b_d_age2 b_d_age3
Here is important to have the same order of varlist: i will use this
macrovar to define an array in a subsequent data step and has to match
to another similar defined array.
Thanks in advance for any help
satya
ps i would also appreciate some links to resources, if any, that
teaches this kind of management with macro variables
|