SAS : Reordering Variables


SAS Analytics : Practical SAS, Statistics & Analysis Course

Suppose you have two datasets with same named variables. You want the order of the variables to be same in both the datasets.

Let's create two datasets
data abc;
input a b c;
cards;
1 3 4
2 4 5
;
run;

data bac;
input b a c;
cards;
1 3 4
2 4 5
;
run;
SAS Code : Reordering Variables
proc sql noprint;
select name
into :reorder
separated by ' '
from dictionary.columns
where libname="WORK" and
memname="ABC"
order by name;
quit;

data bac;
retain &reorder.;
set bac;
run;
Note : Put library and dataset name in LIBNAME and MEMNAME (in caps) in the above code. RETAIN is used to reorder variables in a SAS dataset.
Coursera Data Science

SAS Tutorials : 100 Free SAS Tutorials

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*

Related Posts:

0 Response to "SAS : Reordering Variables"

Post a Comment

Next → ← Prev