Go Back   Rhinocerus > Newsgroup > Newsgroup comp.soft-sys.sas

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 02-11-2006, 06:34 PM
Arthur Tabachneck
Guest
 
Posts: n/a
Default Re: How to build Dynamic Variable names and values

Chandra,

I think you only have to adjust your input statement to account for the
new length of the variable names. For example,

data abc;
set xx;
array aaa amt_sld_prem_disc:;
do over aaa;
if input(substr(vname(aaa),18),best.)=sld_uni_year then new_upb=aaa;
end;
run;

Art
----------
On Sat, 11 Feb 2006 11:50:00 -0500, SUBSCRIBE SAS-L Chandra Gadde
<ddraj2015@GMAIL.COM> wrote:

>Hi Ya,
>
>Thank you, This works fine. But I in my work, I have variables such as
>
>amt_sld_prem_disc11 amt_sld_prem_disc22 amt_sld_prem_disc33
>amt_sld_prem_disc44 amt_sld_prem_disc55 amt_sld_prem_disc66
>amt_sld_prem_disc77 amt_sld_prem_disc88 instead of
>a11 a22 a33 a44 a55 a66 a77 a88.
>
>When I used this code..
>
>data xx;
>input amt_sld_prem_disc11 amt_sld_prem_disc22 amt_sld_prem_disc33
>amt_sld_prem_disc44 amt_sld_prem_disc55 amt_sld_prem_disc66
>amt_sld_prem_disc77 amt_sld_prem_disc88 sld_uni_year amt_sld;
>cards;
>101.12 202 303 404 505 606 707 808 11 333
>111.23 212 313 414 515 616 717 818 22 876
>121.25 222 323 424 525 626 727 828 33 875
>131.25 232 333 434 535 636 737 838 44 765
>;
>run;
>
>data abc;
>set xx;
>array aaa amt_sld_prem_disc:;
>do over aaa;
>if input(substr(vname(aaa),2),best.)=sld_uni_year then new_upb=aaa;
>end;
>run;
>
>
>This was my log...........
>
>
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>amt_sld_prem_disc11=101.12 amt_sld_prem_disc22=202 amt_sld_prem_disc33=303
>amt_sld_prem_disc44=404 amt_sld_prem_disc55=505 amt_sld_prem_disc66=606
>amt_sld_prem_disc77=707 amt_sld_prem_disc88=808 sld_uni_year=11
>amt_sld=333 _I_=9 new_upb=. _ERROR_=1 _N_=1
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>amt_sld_prem_disc11=111.23 amt_sld_prem_disc22=212 amt_sld_prem_disc33=313
>amt_sld_prem_disc44=414 amt_sld_prem_disc55=515 amt_sld_prem_disc66=616
>amt_sld_prem_disc77=717 amt_sld_prem_disc88=818 sld_uni_year=22
>amt_sld=876 _I_=9 new_upb=. _ERROR_=1 _N_=2
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>amt_sld_prem_disc11=121.25 amt_sld_prem_disc22=222 amt_sld_prem_disc33=323
>amt_sld_prem_disc44=424 amt_sld_prem_disc55=525 amt_sld_prem_disc66=626
>amt_sld_prem_disc77=727 amt_sld_prem_disc88=828 sld_uni_year=33
>amt_sld=875 _I_=9 new_upb=. _ERROR_=1 _N_=3
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>NOTE: Invalid argument to function INPUT at line 215 column 4.
>amt_sld_prem_disc11=131.25 amt_sld_prem_disc22=232 amt_sld_prem_disc33=333
>amt_sld_prem_disc44=434 amt_sld_prem_disc55=535 amt_sld_prem_disc66=636
>amt_sld_prem_disc77=737 amt_sld_prem_disc88=838 sld_uni_year=44
>amt_sld=765 _I_=9 new_upb=. _ERROR_=1 _N_=4
>NOTE: Mathematical operations could not be performed at the following
>places. The results of the operations have been set to missing values.
> Each place is given by: (Number of times) at (Line)Column).
> 32 at 215:4
>NOTE: There were 4 observations read from the data set WORK.XX.
>NOTE: The data set WORK.ABC has 4 observations and 11 variables.
>NOTE: DATA statement used:
> real time 0.04 seconds
> cpu time 0.03 seconds
>
>Do you know what is going on here?
>
>Please suggest me.
>
>Thank you.
>
>
>
>
>
>
>
>
>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.

Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How to build Dynamic Variable names and values Peter Crawford Newsgroup comp.soft-sys.sas 0 02-12-2006 06:06 PM
Re: How to build Dynamic Variable names and values SUBSCRIBE SAS-L Chandra Gadde Newsgroup comp.soft-sys.sas 0 02-11-2006 03:50 PM
Re: How to build Dynamic Variable names and values toby dunn Newsgroup comp.soft-sys.sas 1 02-11-2006 03:19 AM
Re: How to build Dynamic Variable names and values Ya Huang Newsgroup comp.soft-sys.sas 0 02-11-2006 02:45 AM
Re: How to build Dynamic Variable names and values Tony Yang Newsgroup comp.soft-sys.sas 0 02-11-2006 01:46 AM



All times are GMT. The time now is 08:38 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.