BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
chelsealutz
Fluorite | Level 6

Hello all! I know there are a ton of "subscript out of range" posts on here, but none of them have helped me identify my problem...

 

data want;
data have;
array barriers(19) $ unawareneed_86 unawarelaterdose_86 unawaretimeplace_86 fearsideeffects_86 longdistanceimmsite_86 toobusy_86 nopermission_86 postponed_86 heardneg_86 timeinconvenient_86 vaccinatorabsent_86 vaccinena_86 famprob_86 childillnottaken_86 childilltakendidnotreceive_86 lackoffaithinimm_86 longwaittime_86 lackoftrustinstaff_86 other_86; array barriercited(19) barriercited1-barriercited19; do i=1 to 19; if barriers(i)='Yes' then barriercited(i)=1; else if barriers(i)='No' then vacchx(i)=0; end; numberbarriers=sum(of barriercited(*)); run;

I keep getting this error: "ERROR: Array subscript out of range at line 13972 column 43" (although the numbers tend to change when I re-run it each time. Hoping fresh eyes will help! Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
else if barriers(i)='No' then vacchx(i)=0;

 

You're referencing another array that doesn't seem to be declared anywhere.

View solution in original post

5 REPLIES 5
Reeza
Super User
else if barriers(i)='No' then vacchx(i)=0;

 

You're referencing another array that doesn't seem to be declared anywhere.

chelsealutz
Fluorite | Level 6

I noticed that literally as soon as I posted the discussion - I thought I deleted it. Guess that's what I get for copy/paste. Thanks though!

FreelanceReinh
Jade | Level 19

The error messages from an undeclared array are different, though.

ERROR: Undeclared array referenced: vacchx.
ERROR: Variable vacchx has not been declared as an array.

So, I'm not sure how this mistake could explain the "subscript out of range" message.

Astounding
PROC Star

Most likely, you will need to post your actual program.  It's not just the reference to a nonexistent array, it's also that  you have a second DATA statement instead of a SET statement.  While you've posted all the code that seems relevant from your perspective, "fresh eyes" will need to see the whole program to diagnose this.

chelsealutz
Fluorite | Level 6

Sorry all - it was as @Reeza pointed out and my arrays didn't match. Thank you though!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 5981 views
  • 1 like
  • 4 in conversation