Date: Fri, 11 Nov 2005 12:14:46 -0500
Reply-To: Peter Crawford <peter.crawford@BLUEYONDER.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Peter Crawford <peter.crawford@BLUEYONDER.CO.UK>
Subject: Re: Change the order of Variable's in a SAS dataset
On Fri, 11 Nov 2005 08:48:01 -0800, Richie <gsingh24@GMAIL.COM> wrote:
>Hi All,
>
>I have a dataset that has variables like:
>Var1 Var2 VarD Var4 Var5 VarA VarB VarC
>
>How can I change the order of the variables to
>VarA VarB VarC Var1 Var2 Var3 Var4 Var5
>
>'VarA VarB VarC' are character and 'Var1 Var2 Var3 Var4 Var5' are
>numeric
>
>Thanks,
>Richie
Unless you have a one-off interest in setting the variable order,
or data that will never be replaced, the best solution is to fix
the order as the data is first written.
rather than "now" revising the data structure, why not change the
code that creates your dataset, so that it creates your data in
the "correct" order?
It just needs a statement, early in the step, defining at least
the name and type/length of each of your variables, and in the
order you want. like:
data your.dataset ;
length VarA $2 VarB $10 VarC $40
Var1 Var2 Var3 Var4 Var5 8;
.....
run;
Of course, I don't know what lengths you want for your character
variables, but you do, so you can put the relevant lengths into
that length statement instead of $2 $10 $40.
Good Luck
Peter Crawford
|