Date: Fri, 1 Aug 2003 16:33:50 -0400
Reply-To: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject: Re: Why is the value of do variable not being restricted?
You probably want to move the SET and BY statements inside the DO loop.
Then LAST.SAP_ID can take on different values as the loop progresses.
On Fri, 1 Aug 2003 16:10:03 -0400, Robert Abelson <rabelson@KAI-
RESEARCH.COM> wrote:
>I spoke too soon, as Master Ian has kindly let me know. It seems that I
>should provide a little more info. Because LAST.SAP_ID in the first
>observation is 0, the stopping condition for the Do Loop will never be
true,
>and the subscript out of range error is the result.
>
>Bob Abelson
>KAI Research, Inc.
>6001 Montrose Rd.
>Suite 920
>Rockville, MD 20852
>T: 301-770-2730
>F: 301-770-4183
>rabelson@kai-research.com
>
>"If you want to inspire confidence, give plenty of statistics. It does not
>matter that they should be accurate, or even intelligible, as long as there
>is enough of them."
>
>-Lewis Carroll
>
>
>> -----Original Message-----
>> From: ma015 b8234 [SMTP:ma015b8234@BLUEYONDER.CO.UK]
>> Sent: Friday, August 01, 2003 3:48 PM
>> To: SAS-L@LISTSERV.UGA.EDU
>> Subject: Why is the value of do variable not being restricted?
>>
>> Dear SAS-L Contributors:
>>
>> I am running this data step and doing array processing.
>> The value of do variable is not being restricted by last.variable;
>> Can anyone tell me what is going on here?
>> SAS Code
>> Data cr_ass.Comms_unique1;
>> set cr_ass.Comms_unique;
>> by SAP_ID;
>> Array comm(10) $12 Comm_No1-Comm_No10;
>> Do i=1 by 1 until (last.SAP_ID) ;
>> Comm(i)=Comm_no;
>> end;
>> run;
>> Data
>> SAP_ID SOURCE_SYS_ID SOURCE_REF_KEY SOURCE_REF_KEY_TYPE
>> COMM_NO
>> COMM_NO_TYPE
>> 10000306 10000306 12246 CT
>> 01494528322 MTEL
>> 10000306 10000306 12247 CT
>> 01494528322 MCTEL
>> 10000327 10000327 12291 CT
>> 01271378299 MTEL
>> 10000327 10000327 12292 CT
>> 01271378299 MCTEL
>> 10000831 10000831 19282 CT
>> 01823334665 MTEL
>> 10000831 10000831 19283 CT
>> 01823334665 MCTEL
>>
>> Log Message
>> Data cr_ass.Comms_unique1;
>> 4 set cr_ass.Comms_unique;
>> 5 by SAP_ID;
>> 6 Array comm(10) $12 Comm_No1-Comm_No10;
>> 7 Do i=1 by 1 until (last.SAP_ID) ;
>> 8 Comm(i)=Comm_no;
>> 9 end;
>> 10 run;
>>
>> ERROR: Array subscript out of range at line 8 column 1.
>> SAP_ID=10000306 SOURCE_SYS_ID=10000306 SOURCE_REF_KEY=12246
>> SOURCE_REF_KEY_TYPE=CT
>> COMM_NO=01494528322 COMM_NO_TYPE=MTEL FIRST.SAP_ID=1
LAST.SAP_ID=0
>> Comm_No1=01494528322
>> Comm_No2=01494528322 Comm_No3=01494528322 Comm_No4=01494528322
>> Comm_No5=01494528322
>> Comm_No6=01494528322 Comm_No7=01494528322 Comm_No8=01494528322
>> Comm_No9=01494528322
>> Comm_No10=01494528322 i=11 _ERROR_=1 _N_=1
>> NOTE: The SAS System stopped processing this step because of
>> errors.
>> NOTE: There were 2 observations read from the data set
>> CR_ASS.COMMS_UNIQUE.
>> WARNING: The data set CR_ASS.COMMS_UNIQUE1 may be incomplete.
When
>> this step was stopped there
>> were 0 observations and 17 variables.
>> WARNING: Data set CR_ASS.COMMS_UNIQUE1 was not replaced because
>> this
>> step was stopped.
>> Thanks in advance for your help
>>
>> John
|