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 2010, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 10 Sep 2010 08:57:53 -0400
Reply-To:     Michael Raithel <michaelraithel@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Michael Raithel <michaelraithel@WESTAT.COM>
Subject:      Re: monthly update
In-Reply-To:  <>
Content-Type: text/plain; charset="us-ascii"

Dear SAS-L-ers,

Data null posted, in part, the following:

> NOTE: PROC DATASETS has a similar function in the AGE statement to > RENAME data sets. This is very useful if you need to keep a number of > backups of a SAS data set. >

<<The entire original posting can be found beneath the sig line>>

Data null, ah yes, and if you think that SAS statement is fun, check out the similar functionality provided by SAS Generation Groups! Examples of both the AGE statement and SAS Generation Groups can be found in my SAS Global Forum 2010 paper:

PROC DATASETS; The Swiss Army Knife of SAS(r) Procedures

...and, of course, in the relevant SAS online documentation:

Data null, best of luck in all of your SAS endeavors!

I hope that this suggestion proves helpful now, and in the future!

Of course, all of these opinions and insights are my own, and do not reflect those of my organization or my associates. All SAS code and/or methodologies specified in this posting are for illustrative purposes only and no warranty is stated or implied as to their accuracy or applicability. People deciding to use information in this posting do so at their own risk.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Michael A. Raithel "The man who wrote the book on performance" E-mail:

Author: Tuning SAS Applications in the MVS Environment

Author: Tuning SAS Applications in the OS/390 and z/OS Environments, Second Edition

Author: The Complete Guide to SAS Indexes

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Tell a man there are 300 billion stars in the universe and he'll believe you. Tell him a bench has wet paint on it and he'll have to touch it to be sure. - Murphy's Law +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<<The entire original posting>>

> Like Mr. Tabachneck I am interested in the how to solve the problem of > "aging" the variable names. I do agree that the data structure is not > good but it is interesting to me to consider how to accomplish the > task of renaming the variables. > > I too tried the rename using a descending enumerated list. If you use > an ascending list there is a variable name clash M0 renamed to M1 > while original M1 still exists and you get an error.. > > The problem with the descending enumerated list is RENAME does not > recognize the descending list properly, M10 is considered smaller > than M2 so you get an ERROR start before end. However, if the list > numbers have leading zeros then the descending rename will work. > > M63-M00=M64=M01 > > And you could actually rename the values with leading zeros, AGE and > rename back, all in ONE rename data set option. > > M0-M63 = M000-M063 > M063-M000 = M064-M001 > M001-M064 = M1-M64 > > But even that part is unnecessary as you can just rename the variables > using an ascending enumerated list with a differnt root and then > rename them back with a different start and stop, like 1-64 > > M0-M63 = ZZ0-ZZ63 > ZZ0-ZZ63 = M1-M64 > > This can all take place in ONE rename data set option and with a > mechanism to determine the largest value of Mnn can be automated to > some degree. > > > data Trans; > do id = 1 to 3; > m0 = ranuni(1243); > output; > end; > run; > data Current; > do id = 1 to 2; > array m[*] m0-m11; > do _n_ = 1 to dim(m); > m[_n_]=_n_; > end; > output; > end; > run; > proc print; > run; > * Find max index of the M variables; > proc sql noprint; > select max(input(substr(name,2),8.)) into :m > from dictionary.columns > where libname='WORK' and memname='CURRENT' and upcase(name) eqT > 'M' > ; > quit; > run; > %let M=&m; > %let P=%eval(&m+1); > %put NOTE: M=&m P=&p; > > data new(/*drop=M&p*/); > merge trans > current > ( > rename= > ( > m0-m&m = _0-_&m > _0-_&m = m1-m&p > ) > ); > by id; > run; > proc contents varnum; > run; > proc print; > run; > > NOTE: PROC DATASETS has a similar function in the AGE statement to > RENAME data sets. This is very useful if you need to keep a number of > backups of a SAS data set. >

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