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 (October 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 4 Oct 2009 14:34:57 -0500
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: Dynamic column ordering
Comments: To: dave crimkey <d_crimkey@yahoo.com>
In-Reply-To:  <745675.79445.qm@web112502.mail.gq1.yahoo.com>
Content-Type: text/plain; charset=ISO-8859-1

They'll be called _200701, _200702, etc., perhaps unless you have validvarnames=any, and perhaps even then. Normally a number starting a variable name is disallowed.

If you then do a proc contents of the resulting dataset and put it out to a dataset (keep NAME), and then run proc sql; select name into :namelist separated by ' ' from contents_dataset order by name; quit; [not at SAS and don't recall if it is NAME or _NAME_, but I think it is NAME]

data new; retain &namelist; set old; run;

With the caveat that you need to both exclude your by variables from the PROC SQL select, and add them at the front of the RETAIN statement before the &namelist macro var.

-Joe

On Sun, Oct 4, 2009 at 2:28 PM, dave crimkey <d_crimkey@yahoo.com> wrote:

> I seem to have two problems. One is that even though Transpose creates > columns 2007 200701 etc., nothing else seems to recognize those column > names.. Here's my transpose -- the values 2007, 200701 etc., are contained > in variable secondvar. I want them ordered in month order so 2007, 200701 - > 200712, 2008, 200801-200812, 2009, 200901-200912. > > proc transpose data=sime out=all ; > byfirstvar thirdvar fourthvar fifthvar; > idsecondvar; > run; > procsortdata=all (drop = _LABEL_); > byfirstvar thirdvar fourthvar fifthvar; > run; > > I've heard that I can use dictionary.columns to dynamically order the > columns the way I want but am not sure how to use that. > > Thanks > > > > > ----- Original Message ---- > From: Arthur Tabachneck <art297@NETSCAPE.NET> > To: SAS-L@LISTSERV.UGA.EDU > Sent: Sunday, October 4, 2009 2:52:06 PM > Subject: Re: Dynamic column ordering > > Dave, > > Please provide the list with some sample data, as well as your proc > transpose > and how you actually want the columns ordered. > > Art > ----- > On Sun, 4 Oct 2009 11:15:23 -0700, dave crimkey <d_crimkey@YAHOO.COM> > wrote: > > >I've created a report that results from a transpose of year/month. Since > the > columns look like the following: 200701 200702.....200909 they are not > coming > out in the correct order. I don't want to hard-code a retain statement in > because I don't want to have to update the statement every month. What is > a > good way of correctly ording the columns? > > > >Thanks, > >Dave >


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