Date: Fri, 14 Mar 2008 16:18:45 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: Finding a variable in a dataset whose name matches a string
value
In-Reply-To: <200803141608.m2EAlst7006377@malibu.cc.uga.edu>
Content-Type: text/plain; charset="iso-8859-1"
Is this what you are looking for:
Data Test ;X1 = 12345 ;Dist = 1 ;U = VValueX( Cats( 'X' , Dist ) ) ;Put X1= U= ;Run ;Toby Dunn "Don't bail. The best gold is at the bottom of barrels of crap." Randy Pausch "Be prepared. Luck is where preparation meets opportunity." Randy Pausch> Date: Fri, 14 Mar 2008 12:08:56 -0400> From: crisgugiu@YAHOO.COM> Subject: Finding a variable in a dataset whose name matches a string value> To: SAS-L@LISTSERV.UGA.EDU> > Hi guys, I'm hoping someone can help me with a little problem I'm having.> I'm trying to create variable X from 5 other variables found in dataset> V1. L1-L4 are constants. I would like the fifth variable U to refer to> another variable in dataset V1 such that when _Dist_=1, U refers to> variable U1, when _Dist_=2, U refers to variable U2, and so on. I've tried> concactinating the value of _Dist_ to the character 'U'. Unfortunately,> this only created a string variable rather than a reference to the right> variable. Is there perhaps a way to loop through the variable contained in> V1 and return the value of the variable whose _Name_ value matches my> string value? Alternative solutions that work are also fine. Here's the> code I was trying to write. Thanks. -Cristian> > > data v2;> set V1;> U=input(compress('U'||_Dist_),4.0);> x = L1 + (U**L3 - (1-U)**L4)/L2;> keep _Dist_ x U;> run;
_________________________________________________________________
Need to know the score, the latest news, or you need your HotmailŪ-get your "fix".
http://www.msnmobilefix.com/Default.aspx |