Can anyone tell me how to reorder some variables if I am having large number of variables in my data set.
There are lot of threads discussing this issue. Use the search facility to fins them.
Give us an example, then someone will help you .
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.
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;
Ksharp
thanks a lot
Hi Kumar,
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.
Thanks,
Shiva
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,
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.