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?
You count i up to 60, and then use i+1 as an index. But there is no element 61.
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;
Thank you for catching that! still getting the same error message though 😕
You count i up to 60, and then use i+1 as an index. But there is no element 61.
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.
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.
Ready to level-up your skills? Choose your own adventure.