BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kyattayk
Calcite | Level 5

Hello all! 

I have a list of coded conditions for patients , organized as such:

 

id dob    HCCategory 1 HCCategory2.. HCCategory60

1 1.6.92        1                       18                      116

2 2.1.88        3                       .                           .  

3 3.8.95        8                       9                        120

3 1.5.00        11                     .                          90

 

I need to conditionally delete 'duplicates' wherein there is two codes for the came condition, but one is more severe.

This is the case for ID 3, bolded above. 8 represents a more severe form of cancer than the cancer represented by 9. 

I would like an array (or other method) to read down the HCCategory columns, and when it sees an 8, delete representatives 

of less severe cancer (numbers 9, 10, 11 and 12) for the following columns, so data looks like this: 

 

id dob    HCCategory 1 HCCategory2..... HCCategory60

1 1.6.92        1                       18                      116

2 2.1.88        3                       .                           .  

3 3.8.95        8                       .                        120

3 1.5.00        11                     .                          90

 

Here is how I'm trying to accomplish this:

 

data test;
set HCCListb;
array hcc[60] HCCategory1-HCCategory60;
do i= 1 to 60;
if hcc[i]= '8' and hcc[i+1] in ('9', '10', '11', '12') then hcc[i+1]= . ;
end;
run;

 

When I run this, I get the following: 

ERROR: Array subscript out of range at line 30 column 4.

 

Any ideas as to what I'm doing wrong? 

1 ACCEPTED SOLUTION
3 REPLIES 3
PaigeMiller
Diamond | Level 26
do i= 1-60;

The value of i is one minus 60, which equals –59. Arrays cannot have subscripts that are 0 or negative.

 

Perhaps you meant

 

do i = 1 to 60;
--
Paige Miller
kyattayk
Calcite | Level 5

Thank you for catching that! still getting the same error message though 😕

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2263 views
  • 3 likes
  • 3 in conversation