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 (May 2003, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 6 May 2003 15:13:45 -0700
Reply-To:   "Huang, Ya" <yhuang@AMYLIN.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Huang, Ya" <yhuang@AMYLIN.COM>
Subject:   Re: How to save typing variable names
Comments:   To: Yibing Chen <yibing_chen@YAHOO.COM>
Content-Type:   text/plain; charset="iso-8859-1"

Yibing,

If all the vars in your data is character like they were shown in your sample, here is a one way to achieve your goal:

DATA A; INPUT @1 Vab $1. @3 Vk $1. @5 Vx $1. @7 Vy $1.; DATALINES; A B C D X Y Z Q I J K L U V W X ;

proc transpose data=a out=b; var v:; run;

data b; set b; if substr(_name_,1,1)='V' then substr(_name_,1,1)='X';

proc transpose data=b out=a (drop=_name_); var col:;

options nocenter; proc print; run; ------------

Obs Xab Xk Xx Xy

1 A B C D 2 X Y Z Q 3 I J K L 4 U V W X

Kind regards,

Ya

-----Original Message----- From: Yibing Chen [mailto:yibing_chen@YAHOO.COM] Sent: Tuesday, May 06, 2003 2:52 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: How to save typing variable names

On Tue, 6 May 2003 15:57:28 -0400, Kevin Viel <kviel@EMORY.EDU> wrote:

>Almost there as far as typing: > >16064 data one; >16065 array x (3) (3*1); >16066 run; > >NOTE: The data set WORK.ONE has 1 observations and 3 variables. >NOTE: DATA statement used: > real time 0.03 seconds > cpu time 0.00 seconds > > >16067 >16068 >16069 data _null_; >16070 set one (rename=(x1-x3=y1-y3)); >16071 put _all_; >16072 run; > >y1=1 y2=1 y3=1 _ERROR_=0 _N_=1 >NOTE: There were 1 observations read from the data set WORK.ONE. >NOTE: DATA statement used: > real time 0.01 seconds > cpu time 0.01 seconds > >Note this works for sequential variables only. For something such as XA, >XB, .... you could use a macro and the SASHELP library... > >Regards, > >Kevin >____________________________________ > >Kevin Viel >Department of Epidemiology >Rollins School of Public Health >Emory University >Atlanta, GA 30329 > > >----- Original Message ----- >From: "Yibing Chen" <yibing_chen@YAHOO.COM> >Newsgroups: bit.listserv.sas-l >To: <SAS-L@LISTSERV.UGA.EDU> >Sent: Tuesday, May 06, 2003 3:28 PM >Subject: How to save typing variable names > > >> Hi, every one, I'm lazy to type. Can you show me how to deal with the >> following rename option that don't have to type each variable. ( I tryed >> rename = (v:=x:). It does not work. >> >> DATA A; >> INPUT @1 V1 $1. @3 V2 $1. @5 V3 $1.; >> DATALINES; >> A B C >> X Y Z >> I J K >> U V W >> ; >> RUN; >> DATA B; >> SET A (RENAME = (V1=X1 V2=X2 V3=X3)); >> RUN; >> >> PROC PRINT DATA=B ; TITLE 'TEST'; RUN; >>

Hi, Kviel

I'm sorry that I did not make my question clear. It should be like that:

DATA A; INPUT @1 Vab $1. @3 Vk $1. @5 Vx $1. Vy; DATALINES; A B C D X Y Z Q I J K L U V W X ; RUN; DATA B; SET A (RENAME = (Vab=Xab Vk=Xk Vx=Xx Vy=Xy)); RUN;

PROC PRINT DATA=B ; TITLE 'TEST'; RUN;


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