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 (June 2000, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 29 Jun 2000 09:35:02 -0400
Reply-To:     Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject:      Re: new variables in new dataset
Comments: To: Toni Zhang <thesis8@HOTMAIL.COM>
Content-Type: text/plain; charset="iso-8859-1"

Toni,

It is a big mistake to bury data (like dates) in variable names. This almost always guarantees that all future programs working with the data will be more complex than necessary. If you want to know more I will be presenting a paper on how to make your programming tasks harder at both SESUG and NESUG. Your suggestion ranks high on the list of possibilities.

It would be far better to interleave the data

data ... ; set .... ( in = a ) .... ( in = b ) ; by .... ; if a then date = "1jan1997"d ; else date = "1jan1998"d ; run ;

That is another rule for easier programming - work with SAS dates. In this case, breaking it would be probably not hurt.

Now to give you an untested answer to the rename problem.

proc sql ; select name || "=" || trim(name) || "97" into :renm97 separated by " " from dictionary.columns where libname = "....." and memname = "....." ; quit ;

proc datasets lib = ..... ; modify ..... ; rename &renm97 ; quit ;

If you are not working in version 8, (you should be) then you will have to worry about names that are too long. Of course, the same problem occurs in 8, but if it does, your names were too long in the first place.

Ian Whitlock <whitloi1@westat.com>

-----Original Message----- From: Toni Zhang [mailto:thesis8@HOTMAIL.COM] Sent: Wednesday, June 28, 2000 5:21 PM To: SAS-L@LISTSERV.UGA.EDU Subject: new variables in new dataset

Hi folks,

I need to merge two data files what has the same variables. One is for 1997 and other is for 1998. Before I merge them I need to rename all the variables (except id)in one data file, say 1997.

I wonder if there is a shortcut that I can use in steade of using 'rename' for every variable. For instance I want

income=97incom food=97food ...

if there is syntax like array or something that I can use it at once to have this done?

Please advise and thanks a lot, Toni

________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


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