- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You count i up to 60, and then use i+1 as an index. But there is no element 61.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for catching that! still getting the same error message though 😕
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You count i up to 60, and then use i+1 as an index. But there is no element 61.