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

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!

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
  • 795 views
  • 0 likes
  • 5 in conversation