@tmcwill wrote:
Hi, thanks again for your responses. Just an FYI, normally I don't care what order variables are in for my own analyses, but I am doing this for another researcher who needs the data in a very specific format in order to use the dataset as an input in an exterior program that will generate a complex figure/plot.
So the OUTPUT has to be in a specific order. Since I haven't run into any SAS procedures that are picky I have to assume that you would be talking about a text file or such in a specific order.
I have done a lot of that, to include specifying rows and columns on a page. Data step and put statements work for that.
Or having the variable names on a VAR statement in Proc Print.
A multitude of like named, or grouped variables could be done with a data step to create long string value that you then stuff into a macro variable.
data example;
length longstring $ 5000;
varlist= "thisvar thatvar othervar";
/* suppose we want to creat 15 grouped variable names
space delimited in a long string*/
do i= 1 to 15; /*the number of groups*/
do j=1 to countw(varlist);
longstring = catx(' ',longstring,cats(scan(varlist,j),i));
end;
end;
call symputx('myvarlist',strip(longstring));
run;
%put the longstring is: &myvarlist.;
Then you could use the macro variable myvarlist such as in
Proc print data=somedataset;
var &myvarlist. ;
run;
or any other place you want that list of variables.
... View more