Date: Thu, 29 Jun 2000 11:15:23 +0100
Reply-To: Peter Crawford <peter.crawford@DB.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Peter Crawford <peter.crawford@DB.COM>
Subject: Re: new variables in new dataset
Content-type: text/plain; charset=us-ascii
Instead of MERGE with the problems of managing two sets of data having the same logical names (ok a lot of renames with the problem of name length) I would suggest using a SET with a BY statement to interleave the information in consecutive observations and apply dif() and lag() functions to perform calculations like
instead of
income=97incom
food=97food
use constructs like
data developm;;
set data97(in=in97) data98(in=in98);
by <idvar like household?>;
if in98 and lag(in97) then
do;
increase = dif( income );
perc_inc = income / lag( income ) -1 ;
...
output;
end;
You would need to be careful to place the OUTPUT statement where you prefer.
This approach will extend to multiple years because there are lagN() functions
Datum: 28/06/2000 22:55
An: SAS-L@listserv.uga.edu
Antwort an: thesis8@hotmail.com
Betreff: new variables in new dataset
Nachrichtentext:
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