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 (July 2009, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 29 Jul 2009 06:47:43 -0500
Reply-To:     Kevin Myers <KevinMyers@AUSTIN.RR.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Kevin Myers <KevinMyers@AUSTIN.RR.COM>
Subject:      Fw: Bug in SCL ARRAY Statement
Comments: cc: SAS Technical Support <support@sas.com>
Content-Type: text/plain; charset="iso-8859-1"

A little birdie's chirping alerted me to a couple of issues regarding my prior message. First off, I re-typed some of that code rather than using copy/paste, and made some typos in the process. The correct code should have been as follows:

main:

/* note the following array has 16777216 elements, NOT 16777215, because it starts with element 0 NOT element 1 */ /* BUG: Only the first element in the array gets initialized to 0, rather than the entire array as intended */ array freq (0:16777215) _temporary_ (16777216*0);

do rgb=0 to 16777215; if freq(rgb)=0 then zeros+1; end;

put zeros=;

return;

The above SCL code only initializes the first element of the array to 0, and prints "zeros=1" to the log, illustrating the bug previously reported. HOWEVER, birdie alerted me to the fact that the following DATA STEP code DOES work properly, and prints "zeros=16777216" to the log:

data _null_;

/* note the following array has 16777216 elements, NOT 16777215, because it starts with element 0 NOT element 1 */ /* the entire array is properly initialized to 0 in data step code, the bug encountered in SCL code does not occur */ array freq (0:16777215) _temporary_ (16777216*0);

do rgb=0 to 16777215; if freq(rgb)=0 then zeros+1; end;

put zeros=;

run;

It seems a bit strange that the reported array initialization problem only exists in SCL rather than data step. One might have expected this restriction in data step due to the max number of variables associated with non-temporary arrays, but it seems to make much less sense that the problem exists in SCL.

Regards, Kevin M.

----- Original Message ----- From: "a little birdie" <birdie@gmail.com> To: "Kevin Myers" <KevinMyers@austin.rr.com> Sent: Tuesday, July 28, 2009 21:25 Subject: Re: Bug in SCL ARRAY Statement

On Jul 28, 2:22 pm, KevinMy...@AUSTIN.RR.COM (Kevin Myers) wrote: > I just noticed a bug in the ARRAY statement in SCL under SAS 8.2. The = > ARRAY statement fails to properly initialize array elements if a = > repetition factor is used that exceeds 32767. Only the first data = > element is initialized in that scenario. Furthermore, using an ARRAY = > statement with nested repetition factors that result in a total = > repetition factor exceeding 32767 also fails, and produces a Write = > Access Violation error. A couple of examples are provided below. > > Question: Does anyone know if this bug still exists in SAS 9.x? I = > don't have access to a SAS 9.x installation at the moment. > > Of course I can work around this problem by coding an appropriate = > initialization loop for the array, but I shouldn't have to do that... > > Thanks, > Kevin M. > > main: > > array freq (0:16777215) _temporary_ (16777216*0); /* this only > initializes the first data element */ > > do rgb=0 to 16777215; > if freq(rgb)=0 then zeros+1; > end; > > put zeros=; > > return; > > When the above code is compiled and executed as an SCL entry, the > following line is written to the SAS log: > > zeros=1 > > main: > > array freq (0:16777215) _temporary_ (256*(256*(256*0))); > > do rgb=0 to 16777215; > if freq(rgb)=0 then zeros+1; > end; > > put zeros=; > > return; > > When the above code is compiled and run as an SCL entry via testaf, the > following error message is produced in the SAS log: > > ERROR: Write Access Violation In Task ( TESTAF ] > Exception occurred at (62764198) > Task Traceback > ERROR: Generic critical error.

Kevin ... examination of the code shows that the size of the array and the "multiplier" for the initialization aren't equal. 1677215 ne 16777216 (Note the extra '7' in the multipler) array freq (0:1677215) _temporary_ (16777216*0);

Hope this is helpful ... birdie

I tried this:

proc printto log="log.log" new;run; data; array freq (0:1677215) _temporary_ (1677216*0); x = dim (freq); do i = 0 to (x-1); put freq{i} =; end; stop;run; proc printto log=log;run;

which seems to work ...

LOG:

NOTE: PROCEDURE PRINTTO used (Total process time): real time 0.01 seconds cpu time 0.01 seconds

40 data; 41 array freq (0:1677215) _temporary_ (1677216*0); 42 x = dim(freq); 43 do i = 0 to (x-1); 44 put freq{i}=; 45 end; 46 stop;run;

freq[0]=0 freq[1]=0 freq[2]=0 freq[3]=0 freq[4]=0 freq[5]=0 freq[6]=0 freq[7]=0 freq[8]=0 freq[9]=0 freq[10]=0 freq[11]=0 freq[12]=0 freq[13]=0 freq[14]=0 freq[15]=0 freq[16]=0 freq[17]=0 freq[18]=0 freq[19]=0 freq[20]=0 .... snip

freq[1677210]=0 freq[1677211]=0 freq[1677212]=0 freq[1677213]=0 freq[1677214]=0 freq[1677215]=0 NOTE: The data set WORK.DATA6 has 0 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 1.87 seconds cpu time 1.76 seconds

47 proc printto log=log;run;


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