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 (February 2006, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 10 Feb 2006 22:45:20 -0500
Reply-To:     Ya Huang <ya.huang@AMYLIN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ya Huang <ya.huang@AMYLIN.COM>
Subject:      Re: How to build Dynamic Variable names and values
Comments: To: Toby Dunn <tobydunn@HOTMAIL.COM>

for v8, you can try vname() + array:

data xx; input a11 a22 a33 a44 a55 a66 a77 a88 x; array aaa a:; do over aaa; if input(substr(vname(aaa),2),best.)=x then new_upb=aaa; end; cards; 101 202 303 404 505 606 707 808 11 111 212 313 414 515 616 717 818 22 121 222 323 424 525 626 727 828 33 131 232 333 434 535 636 737 838 44 ;

proc print; run;

a11 a22 a33 a44 a55 a66 a77 a88 x new_upb

101 202 303 404 505 606 707 808 11 101 111 212 313 414 515 616 717 818 22 212 121 222 323 424 525 626 727 828 33 323 131 232 333 434 535 636 737 838 44 434

Ya

On Sat, 11 Feb 2006 01:42:10 +0000, toby dunn <tobydunn@HOTMAIL.COM> wrote:

>chandra , > >If you have v9 you can do: > >new_upb = vvaluex('a'||left(x)) ; > > > >Toby Dunn > > > > > >From: SUBSCRIBE SAS-L Chandra Gadde <ddraj2015@GMAIL.COM> >Reply-To: SUBSCRIBE SAS-L Chandra Gadde <ddraj2015@GMAIL.COM> >To: SAS-L@LISTSERV.UGA.EDU >Subject: How to build Dynamic Variable names and values >Date: Fri, 10 Feb 2006 20:02:01 -0500 > >Hello Everyone, > >Here is my scenario. > >I have a dataset named dsn. Here is how it looks. > >a11 a22 a33 a44 a55 a66 a77 a88 x >101 202 303 404 505 606 707 808 11 >111 212 313 414 515 616 717 818 22 >121 222 323 424 525 626 727 828 33 >131 232 333 434 535 636 737 838 44 > >Now, I need to create a new variable calld new_upb such that > >new_upb = a(x); > >Meaning if the value of x = 11 then new_upb = a11 (a11=101 in our case). > >In other words, New dataset will look like this > >a11 a22 a33 a44 a55 a66 a77 a88 x new_upb >101 202 303 404 505 606 707 808 11 101 >111 212 313 414 515 616 717 818 22 212 >121 222 323 424 525 626 727 828 33 323 >131 232 333 434 535 636 737 838 44 434 > >Could you please help me. > >Thank you.


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