LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2011, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 17 Feb 2011 11:28:03 -0500
Reply-To:     "Kirby, Ted" <ted.kirby@LEWIN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Kirby, Ted" <ted.kirby@LEWIN.COM>
Subject:      Re: Reordering Variables and Keeping Variables
In-Reply-To:  A<2A0E36BA7ED340C798D850DAD42B0ACB@D1871RB1>
Content-Type: text/plain; charset="us-ascii"

Although, I do not think that this code will leave the variables in the new order. One solution would be to use PROC SQL;

PROC SQL; create table want as select d,c,b,a from have; quit;

Ted Kirby, Consultant, The Lewin Group, Inc. 3130 Fairview Park, Suite 800 Falls Church, VA 22042 Phone: (703)269-5507 Fax: (703)269-5501 e-mail: ted.kirby@lewin.com

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Nat Wooding Sent: Wednesday, February 16, 2011 9:14 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Reordering Variables and Keeping Variables

Randy

The rule is that the order that the SAS Supervisor first encounters variables determines the order that they are established in the Program Data Vector. The first appearance of the variables is in the retain statement so that is the order that they will be in the data set. Also, they will all be numeric.

If you do not need the other 46, then the better code would be

Data Want; Retain A B C D; Set have ( keep = A B C D ); Run;

Nat Wooding

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Randy Sent: Wednesday, February 16, 2011 9:02 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Reordering Variables and Keeping Variables

My data set has more than 50 variables. I want to keep some of them and reorder them in a particular way. Is this correct?

Data want; Retain A B C D ; Keep D B C A; set have; run;

Or does the keep statement suffice? Thanks Randy ************* IMPORTANT - PLEASE READ ********************

This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately.


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