Hi,
I have a variable that consists information about diagnosis (6496 different diagnosis). For each diagnosis i want to create a dummy variable and i used this code:
DATA b2; set b; ARRAY dummys {*} 3. diag1_1 - diag1_6496; DO i=1 TO 6496; dummys(i) = 0; END; dummys( diag1 ) = 1; RUN;
However, I get this error message:
Array subscript out of range at line 2087 column 1.
Can anyone tel me what is wrong with code?
thank you
With such errors, you get a listing of all variables and their values in the log. Look for the value of diag1. It might be zero or missing.
Obviously, the value of the DIAG1 variable is not always between 1 and 6496. Is it missing or 0 in some observations? What does the log say about the value of DIAG1 when the error occurs?
Still better: run a proc freq on diag1 and inspect the result.
Thanks,
There is no 0 or missing values; however, I found what was wrong with code (my values were letters not numbers) and I made it work
I would question why you want to do this. Just take a simple example of having two records:
DIAG
34
26
This is two datapoints of information. If you transpose that into your structure, you would have 6496 datapoints of information. This is just a simple example of where your intended data structure is very verbose in terms of storage, but you will also find your coding is far harder as well.
data have;
set sashelp.class;
dummy=1;
run;
proc logistic data=have outdesign=want outdesignonly;
class name/param=glm;
model dummy=name;
run;
proc print data=want(drop=dummy intercept) noobs;run;
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.