BookmarkSubscribeRSS Feed
viollete
Calcite | Level 5

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

6 REPLIES 6
s_lassen
Meteorite | Level 14

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?

viollete
Calcite | Level 5

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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

 

Ksharp
Super User
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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

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
  • 6 replies
  • 809 views
  • 0 likes
  • 5 in conversation