Help using Base SAS procedures

Illegal reference to the array Symptoms

Accepted Solution Solved
Reply
Contributor
Posts: 20
Accepted Solution

Illegal reference to the array Symptoms

Can anyone tell me what is wrong here?

 

334 DATA Felibertiloop; set Felibertiloop;
335 array Symptoms[3] Symptoms1-Symptoms3;
336 **Output if all symptoms are missing;
337 IF max( of Symptoms(*)) = . then output;
338 ELSE DO I=1 to 3;
339 **Only output when sides are not missing;
340 Symptoms=Symptoms(i);
ERROR: Illegal reference to the array Symptoms.
341 IF not missing(Symptoms) then output;
ERROR: Illegal reference to the array Symptoms.
342 end;
343 drop i;
344 RUN;



Accepted Solutions
Solution
‎05-25-2017 10:15 AM
Super User
Posts: 6,938

Re: Illegal reference to the array Symptoms

Symptoms=Symptoms(i);

The left side of the assignment misses the necessary index for the array element.

Same happens in the next line.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎05-25-2017 10:15 AM
Super User
Posts: 6,938

Re: Illegal reference to the array Symptoms

Symptoms=Symptoms(i);

The left side of the assignment misses the necessary index for the array element.

Same happens in the next line.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 20

Re: Illegal reference to the array Symptoms

Actually figured it out right after I posted this. Tried to delete post, forgot to press "Confirm". Too late now. Thanks anyway.
Super User
Posts: 5,083

Re: Illegal reference to the array Symptoms

Once you have an array named Symptoms, you can't use that name to represent anything else.  In this case, you are trying to create a variable named Symptoms as well, which SAS finds illegal.  Change the variable name to something else.

 

SAS is so fussy about reusing an array name that you would also get an error for this:

 

array symptoms {3} symptom1-symptom3;

array symptoms {3} symptom1-symptom3;

 

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 171 views
  • 0 likes
  • 3 in conversation