I used to have this problem before, and I could suggest two ways of
in PDV. Let's say that you have data set X with variables A, B, C and D and
you want to
create data set Y where variables will be ordered as D, C, B and A.
The first technique is to use RETAIN before SET:
retain d c b a;
The disadvantage of this approach is that you will have to reread you
original data, what
you do not want to do in general (you want just change order of variables in
As an alternative I can suggest the following technique:
1. First run the following SQL :
proc sql ;
describe table x;
2. Go to your log and copy the SAS code SQL created and paste it back to
create table WORK.X( bufsize=4096 )
3. Using copy and paste rearrange variables order
create table WORK.y( bufsize=4096 )
4. Run the above code with the following PROC APPEND
proc append base=y data=x;run;
The idea behind this is that does not matter how big is your original data
set in steps
1, 2 and 3 you are working and creating just descriptor portion. Appending
more efficient then DATA-SET syntax which require rereading the entire data.
Hope this would help. Good luck!
From: Joel Winter [mailto:jpwinter@UMSL.EDU]
Sent: Tuesday, May 02, 2000 9:18 AM
Subject: Most efficient way to chang variable order in data set
I received a quite large data set (> 3000 cases, > 2000) variables. I
would like to chop things down to a more manageable size.
The variables represent survey items. Numbering for survey items is
somewhat akward (eg, q1 q2 q2a q2oth q3). Plus, the variable ordering
in the data set is off from the ordering on the surveys. I would like
to get the order back to the survey ordering, so that I can safely use
variable ranges (eg, q1--q3).
The variable are a mix of numeric and string, and have labels.
Any suggestions are greatly appreciated.