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!
else if barriers(i)='No' then vacchx(i)=0;
You're referencing another array that doesn't seem to be declared anywhere.
else if barriers(i)='No' then vacchx(i)=0;
You're referencing another array that doesn't seem to be declared anywhere.
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!
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.
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.
Sorry all - it was as @Reeza pointed out and my arrays didn't match. Thank you though!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.