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:         Sat, 11 Feb 2006 18:10:25 -0500
Reply-To:     SUBSCRIBE SAS-L Chandra Gadde <ddraj2015@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         SUBSCRIBE SAS-L Chandra Gadde <ddraj2015@GMAIL.COM>
Subject:      Re: How to build Dynamic Variable names and values

Hi Puddin',

I still couldn't get the answer. I am running the same code but somehow I am getting the error.

ERROR: Array subscript out of range at line 509 column 14.

I think the number 10 shold be greater than the total number of variables in the array. But still somehow I couldn't figure out why I am receiving that error.

Here are my original columns.

amt_sld_upb_rstrtd(i), amt_sld_prem_disc(i), amt_sld_proceed(i) where i = 1 to 13. (I have around 800 variables in that dataset).

Please suggest me. Chandra,

If you can comprehend the following log/list stuff, perhaps you can lay this dawg to rest:

337 data rr; 338 input a11 a22 a33 a44 a55 a66 a77 a88 x; 339 cards;

NOTE: The data set WORK.RR has 8 observations and 9 variables. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.02 seconds

348 ; run; 349 350 data ss; 351 set rr; 352 array a(8) a11 a22 a33 a44 a55 a66 a77 a88; 353 new_upb = a(mod(x, 10)); 354 run;

NOTE: There were 8 observations read from the data set WORK.RR. NOTE: The data set WORK.SS has 8 observations and 10 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.02 seconds 355 356 proc print; run;

NOTE: There were 8 observations read from the data set WORK.SS. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.01 seconds

The SAS System 5

Obs a11 a22 a33 a44 a55 a66 a77 a88 x new_upb

1 101 202 303 404 505 606 707 808 11 101 2 111 212 313 414 515 616 717 818 22 212 3 121 222 323 424 525 626 727 828 33 323 4 131 232 333 434 535 636 737 838 44 434 5 101 202 303 404 505 606 707 808 77 707 6 111 212 313 414 515 616 717 818 55 515 7 121 222 323 424 525 626 727 828 88 828 8 131 232 333 434 535 636 737 838 66 636

Prosit, Puddin'

***************************************************************** *** Puddin' Man PuddingDotMan at GmailDotCom ** *****************************************************************;

On 2/11/06, SUBSCRIBE SAS-L Chandra Gadde <ddraj2015@gmail.com> wrote: > Art, > > I tried with all possible numbers in my input statement. I am still > getting the same warings in log. > > I also tried Puddin's code.. > > data rr; > input a11 a22 a33 a44 a55 a66 a77 a88 x; > array a(*) a:; > new_upb = a(mod(x, 10)); > cards; > > But it is saying that > ERROR: Array subscript out of range at line 1735 column 14. > > I have two answers but I couldn't use none of them because of errors. > Would you please help me out? > > Thank you. > > > 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. >


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