04-20-2012 04:35 AM
suppose I am having variables in the order- visit patno pat_initials body_temp1 sbp1 dbp1 pulserate1 body_temp2 sbp2 dbp2 pulserate2
and I want to arrange these variables in the order-patno visit pat_initials body_temp1 body_temp2 sbp1 sbp2 dbp1 dbp2 pulserate1 pulserate2.
It is just an example.
04-20-2012 04:59 AM
OK. You can create a format to customize the order of variables.
data have; input (visit patno pat_initials body_temp1 sbp1 dbp1 pulserate1 body_temp2 sbp2 dbp2 pulserate2) ($); cards; 1 2 3 4 5 3 4 5 4 3 2 2 2 2 2 2 2 2 2 2 2 2 2 ; run; proc sql; select name into : list separated by ' ' from dictionary.columns where libname='WORK' and memname='HAVE' and name not in ('visit' 'patno' 'pat_initials') order by scan(name,1,' ','d'),input(scan(name,1,' ' ,'kd'),best32.); quit; %put &list; data want; retain patno visit pat_initials &list; set have; run;
04-20-2012 05:00 AM
You can use length statement(if you define length for particular column it will come first ,if you don't want to change the order then don't define that variable in length statement) or you can use Column in proc report.
04-20-2012 11:02 AM
Hi ... one issue with using LENGTH is making sure that the lengths provided for the variables match those already in the data set that is being reordered. I think that one is safer with the more standard solution that Ksharp proposed, using a RETAIN statement where no attributes of the variables are needed,