LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (January 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
In-Reply-To:  <200601182040.k0IKaiBp013556@mailgw.cc.uga.edu>
Content-Type: text/plain; format=flowed

excel_hari@YAHOO.COM wrote: >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 statement. 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 sashelp.vcolumn view.) Then you can pull the variables (and information on them) into another table, output them, etc.

HTH, David -- David L. Cassell mathematical statistician Design Pathways 3115 NW Norwood Pl. Corvallis OR 97330

_________________________________________________________________ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


Back to: Top of message | Previous page | Main SAS-L page