Date: Thu, 19 Jan 2006 11:37:47 -0800
Reply-To: David L Cassell <davidlcassell@MSN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: David L Cassell <davidlcassell@MSN.COM>
Subject: Re: Ordering variables in data file
Content-Type: text/plain; format=flowed
>2 some-what related doubts:-
>a) How do I change the order of variables in SAS. The keep
>option/statement is there for retaining variables but it doesnt change
>the order. (In SPSS keep canges the order as well)
But not in SAS.
If you have a SAS data set already, then definitely use the RETAIN
Before your SET statement. This works even if you have missing values.
>b) I can probably handle a) (in roundabout manner) by using proc SQL
>where I write the variables within select staement in the order I want
>it to appear in file. But again, in SAS is there a easy (and
>"sensical") method to output all the variables in data file in to lets
>say Log or output window. (In SPSS one can paste the variables to
>editor using paste syntax from GUI pull-down).
Yes, you can use PROC SQL to do re-ordering of the values as well.
But in general I do not bother. You can get whatever order you want at
any time in any display proc, courtesy of the VAR statement.
But when you are interested in a list of variables from any SAS data set,
you should look at the meta-data. Use PROC SQL to access the
dictionary.columns table. (Or use a data step to look at the
view.) Then you can pull the variables (and information on them) into
another table, output them, etc.
David L. Cassell
3115 NW Norwood Pl.
Corvallis OR 97330
Express yourself instantly with MSN Messenger! Download today - it's FREE!