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

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 11-07-2008, 02:32 PM
Arthur Tabachneck
Guest
 
Posts: n/a
Default Re: weird problem with array name

Now you've raised my curiosity. The following works on my machine (sas
9.1.3 in a windows 2003 server environment):

data apusof_tot3 ;
input x award1-award6 paymnt1-paymnt9;
array awrdr[6] award1-award6 ;
array pmtr[9] paymnt1-paymnt9 ;
array awd[10,8] ;
array pmt[10,12] ;
array yrs[10] ;
array code[10] $ 6 ;
retain pmt yrs code awd ;
do i=1 to 10;
do j=1 to 8;
awd(i,j)=1;
end;
do j=1 to 12;
pmt(i,j)=1;
end;
yrs(i)=1;
code(i)='abcdef';
end;
cards;
1 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9
2 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9
3 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9
4 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9
5 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9
;

Will the above code run correctly on your machine? If not, what version
of SAS are you using and in with which operating system?

Art
-------
On Fri, 7 Nov 2008 04:06:01 -0800, Davwein <dav.wein@COMCAST.NET> wrote:

>On Nov 6, 8:56 pm, Nord...@DSHS.WA.GOV ("Nordlund, Dan (DSHS/RDA)")
>wrote:
>> > -----Original Message-----
>> > From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On
>> > Behalf Of Davwein
>> > Sent: Thursday, November 06, 2008 5:33 PM
>> > To: SA...@LISTSERV.UGA.EDU
>> > Subject: weird problem with array name

>>
>> > I was creating a small bit of code to combine records using arrays.
>> > One variable of interest was financial aid awards, so I created an
>> > array with the name awd[10,8]. This array was used to collect data
>> > across multiple records so I included it in a retain statement:

>>
>> > data sasc.apusof_tot3 ;
>> > set sasc.apusof_tot2 (obs=20) ;
>> > by key ;
>> > file print ;
>> > array awrdr[6] award1-award6 ;
>> > array pmtr[9] paymnt1-paymnt9 ;
>> > array awd[10,8] ;
>> > array pay[10,12] ;
>> > array yrs[10] ;
>> > array code[10] $ 6 ;
>> > retain pay yrs code awd ;
>> > ...

>>
>> > When I begin checking the code I found errors in this array when
>> > reading 2nd and later records in the group and determined that the
>> > array was not retaining data in the first 8 positions. I had
>> > previously used pmt[10,12] and got a warning from SAS about a pmt()
>> > function, but the code still worked. But I changed it to pay[10,12] in
>> > the hopes it would fix the problem with the awd array. No joy. After
>> > printing results out and all critical junctures of the program, I
>> > could not find a coding error.

>>
>> > Being desperate, I decided to change the name of the array to
>> > awrd[10,8]. Now the code worked perfectly.

>>
>> > I tried to determine if there was a SAS function awd() but could not
>> > find one. Note that the other arrays in the retain statement had no
>> > problems in retaining values.

>>
>> > Can anyone enlighten me?

>>
>> Try declaring your pay, yrs, code, and awd arrays as temporary and

eliminate the retain statement. Temporary arrays are automatically
retained.
>>
>> data sasc.apusof_tot3 ;
>> set sasc.apusof_tot2 (obs=20) ;
>> by key ;
>> file print ;
>> array awrdr[6] award1-award6 ;
>> array pmtr[9] paymnt1-paymnt9 ;
>> array awd[10,8] _temporary_ ;
>> array pay[10,12] _temporary_ ;
>> array yrs[10] _temporary_ ;
>> array code[10] $6 _temporary_ ;
>> ...
>>
>> Hope this is helpful,
>>
>> Dan10.8]
>>
>> Daniel J. Nordlund
>> Washington State Department of Social and Health Services
>> Planning, Performance, and Accountability
>> Research and Data Analysis Division
>> Olympia, WA 98504-5204

>
>I did solve the problem by giving the array a different name - was
>just wondering why awrd[10,8] works while awd[10,8] does not. Thanks
>for the tip on temporary spec - didn't know that.

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
weird problem with array name Davwein Newsgroup comp.soft-sys.sas 0 11-07-2008 12:33 AM
Re: Newbie SAS Array problem (take 2) Jim Groeneveld Newsgroup comp.soft-sys.sas 2 01-09-2006 01:04 PM
Re: Array problem Guido T Newsgroup comp.soft-sys.sas 0 06-23-2005 07:37 AM
Array problem Paul Newsgroup comp.soft-sys.sas 0 06-23-2005 07:10 AM
Re: find maximum vaule in sas array Paul M. Dorfman Newsgroup comp.soft-sys.sas 0 04-27-2005 05:27 AM



All times are GMT. The time now is 03:22 AM.


Copyright ©2009

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