| Date: | Tue, 1 Aug 2006 16:36:20 +0530 |
| Reply-To: | Bhavani Shankar <bhavani.shankar@INDIA.BIRLASOFT.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Bhavani Shankar <bhavani.shankar@INDIA.BIRLASOFT.COM> |
| Subject: | Re: Rename |
|
| Content-Type: | text/plain; charset=us-ascii |
Hi
I use this macro when there are N number of records/observations.
/* SAS code to prefix variables */
/* create unique macro variable for each variable */
data _null_;
set out1;
call symput('var'||trim(left(_N_)),trim(left(name)));
call symput('nobs',trim(left(_N_)));
run;
%macro rename;
data outdata;
set input;
rename %do i=1 %to &nobs;
&&var&i= NEW_&&var&i
%end; ;
run;
%mend;
%rename;
Thanks & Regards
Bhavani
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Alexsander_Sebastiar
Sent: Tuesday, August 01, 2006 3:55 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Rename
Hi Yom,
I hope this below code will work for you.
------------------------------------------------------------------------
-------------------------------
Data input;
Var1="a";
Var2="b";
Var3="c";
Var4="d";
output;
Var1="q";
Var2="w";
Var3="r";
Var4="t";
output;
Run;
%macro x();
data Output;
set Input;
array vars{*} var:;
%do i=1 %to 4;
rename var&i=new&i;
%end;
run;
%mend;
%x();
------------------------------------------------------------------------
-------------------------------
Thanks n Regards,
Alexsander S,
| Software Engineer | Satyam | Bangalore |
| 09845 356898 |
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of yom
Sent: Thursday, July 27, 2006 4:47 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Rename
Dear All,
Is there a simple way to rename variables whose prefix is regular.
For example :
I would like to rename VAR1 VAR5 VAR12 VAR27 in NEW1 NEW5 NEW12 NEW27.
Thank you very much in advance !
yom
DISCLAIMER:
This email (including any attachments) is intended for the sole use of
the intended recipient/s and may contain material that is CONFIDENTIAL
AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or
copying or distribution or forwarding of any or all of the contents in
this message is STRICTLY PROHIBITED. If you are not the intended
recipient, please contact the sender by email and delete all copies;
your cooperation in this regard is appreciated.
*********************************************************************************************************************************************************************
"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient,any disclosure,copying, use, or distribution of the information included in this message and any attachments is
prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
*********************************************************************************************************************************************************************
|