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 (September 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 11 Sep 2007 22:51:01 -0400
Reply-To:     "Keintz, H. Mark" <mkeintz@WHARTON.UPENN.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Keintz, H. Mark" <mkeintz@WHARTON.UPENN.EDU>
Subject:      Re: Why won't RETAIN accept a variable list?
Comments: To: toby dunn <tobydunn@HOTMAIL.COM>
In-Reply-To:  A<BAY123-F36DAFAB68A44B762F4D932DEC20@phx.gbl>
Content-Type: text/plain; charset="us-ascii"

But the form a1-a10 (single dash) DOES work, because the list construction is determined entirely from the endpoints. No PDV information review is required. So you could do this:

data want1a; retain industry ae2004-ae2007 ae2011; set have; run;

Of course that depends on knowing which variables are actually in HAVE (i.e. I deliberately excluded ae2008 ae2009 and ae2010).

But it turns out you don't even have to be that aware of the vars in HAVE. If you're willing to tolerate some "NOTE: variable xxx is uninitialized." entries on your log, try this:

data want1b; retain industry ae2004-ae2011; set have; run;

It makes a note of the uninitialized variables ae2008 ae2009 and ae2010, BUT IT DOESN'T ADD THEM TO DATA SET WANT1B. This is unlike other statements that generate the "variable is uninitialized" note, like the length statement here:

data want1c; retain industry ae2004-ae2001; length m; set have; run;

Variable m will be noted as uninitialized, and added to want1c. Variables ae008-ae2010 will only get the notes.

Be careful not to add a retain VALUE at the end of the retain statement. Then ae2008-ae2010 would also be added to the data set.

Good luck, Mark

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > toby dunn > Sent: Tuesday, September 11, 2007 8:41 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: Why won't RETAIN accept a variable list? > > I need to make one small correction, when you use the short cut A1--A10 > or > A1-A10 You can use A: > > > > Toby Dunn > > Compromise is like telling a lie, it gets easier and easier. Each > comprimise you make, that becomes your standard. > > Perfection doesnt exist, once you reach it, its not perfect anymore. > It > means something else. > > > > > > From: Arthur Tabachneck <art297@NETSCAPE.NET> > Reply-To: Arthur Tabachneck <art297@NETSCAPE.NET> > To: SAS-L@LISTSERV.UGA.EDU > Subject: Why won't RETAIN accept a variable list? > Date: Tue, 11 Sep 2007 19:03:21 -0400 > > Is there something I missed in the documentation that would explain why > the code to create file 'want1' won't run, but the code to create > file 'want2' works perfectly?: > > data have; > input industry x y z ae2004 ae2005 ae2006 ae2007 ae2011; > cards; > 1 0 0 0 1 2 3 4 5 > 2 0 0 0 5 4 3 2 1 > ; > > data want1; > retain industry ae2004--ae2011; > set have; > run; > > data want2; > retain industry ae2004 ae2005 ae2006 ae2007 ae2011; > set have; > run; > > Art > > P.S. For Enquiring Minds, I'm only using retain to rearrange the data > prior to exporting it to a spreadsheet. > > _________________________________________________________________ > Get a FREE small business Web site and more from Microsoft(r) Office > Live! > http://clk.atdmt.com/MRT/go/aub0930003811mrt/direct/01/


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