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:   Wed, 18 Jan 2006 13:48:57 -0800
Reply-To:   Bill McKirgan <bill-mckirgan@UIOWA.EDU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Bill McKirgan <bill-mckirgan@UIOWA.EDU>
Organization:   http://groups.google.com
Subject:   Re: Ordering variables in data file
Comments:   To: sas-l@uga.edu
In-Reply-To:   <1137616776.662003.80820@g49g2000cwa.googlegroups.com>
Content-Type:   text/plain; charset="iso-8859-1"

Hari,

The RETAIN statment is one way to change the order of variables in SAS datasets.

The trick is to put RETAIN between the DATA and SET statements like so...

data foo; input var2 var9 var3 var1 ID; put (_all_) (=);

cards; 1 2 3 4 97 4 2 . 1 98 2 3 4 5 99 ; run;

data reorder; retain id var1 var2 var3 var9; set foo; put (_all_) (=); run;

id=97 var1=4 var2=1 var3=3 var9=2 id=98 var1=1 var2=4 var3=. var9=2 id=99 var1=5 var2=2 var3=4 var9=3

Kind regards, Bill


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