Hello,
I'm having trouble debugging my error and could really use some help. Here is my code with the line numbers and I keep getting the error: Array subscript out of range.
2060 data prescribercount (keep=patientid prescribers1 prescribers2);
2061 set prescriptions1;
2062 by patientid half prescriber;
2063 array prescribers(2) prescribers1 prescribers2;
2064 retain prescribers1-prescribers2 0;
2065 if first.prescriber then prescribers(half)=prescribers(half)+1;
2066 else if last.patientid then do;
2067 output;
2068 prescribers1=0;
2069 prescribers2=0;
2070 end;
2071 run;
ERROR: Array subscript out of range at line 2065 column 44.
Would really appreciate insights.
Thanks!!
What values does your variable HALF take on?
Your array definition sets the array to only accept 1 and 2. If half ever has any other value that will cause the error.
Run proc freq on the input data set and the variable Half to confirm what you might believe.
What values does your variable HALF take on?
Your array definition sets the array to only accept 1 and 2. If half ever has any other value that will cause the error.
Run proc freq on the input data set and the variable Half to confirm what you might believe.
Thank you!! You were right. It turned out that HALF had all missing variables. The variable names in a previous code didn't match what was supposed to be in this SAS code and thus HALF didn't get coded properly.
Appreciate your prompt support!
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 how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.