| Date: | Thu, 29 Jun 2000 08:29:59 -0400 |
| Reply-To: | "Confer, Edward" <EConfer@S-3.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Confer, Edward" <EConfer@S-3.COM> |
| Subject: | Re: new variables in new dataset |
|
| Content-Type: | text/plain; charset="iso-8859-1" |
|---|
options mprint symbolgen;
%macro loop;
data data1;
samples=1;
actuals=1;
somevar=1;
anyvar=1;
income=1;
taxes=1;
run;
proc contents noprint data=data1 out=content(keep=name);
run;
proc sql noprint;
select name into :list seperated by ' ' from content;
%put &list;
Toni,
Here is something I developed that is relatively easy to program.
Substitute in the values for 'M' counter and 'K' counter based on the number
of variables you are renaming. IN the Contents Proc, do a keep on those you
want to rename. Important to realize I did this with very distinct 7 - 8
length vars and at 5 they were still distinct. If yours are less, you may
want to adjust. Also, a number cannot lead a variable name.
Ed
data _null_;
x="&list";
%do k=1 %to 6;
call symput("var&k",scan(x,&k,' '));
call symput("varx&k",substr(scan(x,&k,' '),1,5));
%end;
run;
data data1;
set data1;
%do m=1 %to 6;
rename
&&var&m=&&varx&m..97;
%end;
run;
proc print ;
run;
%mend;
%loop;
-----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
|