02-23-2012 10:10 PM
I am sure there will be better approaches, but given it is alreay 10pm est, you may not get them as timely as you wanted. So here is one option for you:
input b a c e d;
1 2 3 4 5
proc contents data=have out=have1;
select name into :name separated by ' ' from have1;
of course, one variation of this solution is to Proc SQL for the second half part of it:
select name into :name separated by ',' from have1;
create table want as select &name from have; quit;
02-23-2012 11:15 PM
Just found out that there is something worth mentioning of my solution: the case. You may want to add an option if you want to ignore the case:
proc contents data=have out=have1 order=ignorecase;
otherwise it will put upper case variable names ahead of those lower case.
02-23-2012 10:47 PM
There is always the pure SQL solution:
proc sql noprint;
into :names separated by ","
where libname="SASHELP" and
order by name
create table want
as select &names.
02-23-2012 10:48 PM
What does that mean? Normally when you talk of sorting a dataset you mean sorting the observations.
Are you saying you want to create a copy of the data with the variables ordered alphabetically by their name rather than their original position?
Need further help from the community? Please ask a new question.