ID | ICD1 | ICD2 | ICD3 | ICD4 | ICD5 |
---|---|---|---|---|---|
1001 | 808.1 | 201 | 101.9 | 003 | 922 |
1002 | 421.0 | 556 | 707.3 | 997 | |
1003 | 787.2 | 308 | 599.8 |
I have 5 ICD codes in 5 columns, they are character variables. I want to be able to count how many valid values each subject has in the 5 ICD columns. So, for 1001, the result would be 5, for 1002 it will be 4 and 1003 will be 3. Or we could see it as the number of missing values in an array of variables per subject. Thank you.
for character variables you would use the function cmiss().
For count of not missing:
data want;
set have;
valid = 5 - cmiss(of icd1-icd5);
run;
or for count of missing:
data want;
set have;
valid = cmiss(of icd1-icd5);
run;
in a data step:
data want;
set have;
numvalid = n( of ICD1-icd5);
run;
The function NMISS with the same basic syntax would give the missing per record.
for character variables you would use the function cmiss().
For count of not missing:
data want;
set have;
valid = 5 - cmiss(of icd1-icd5);
run;
or for count of missing:
data want;
set have;
valid = cmiss(of icd1-icd5);
run;
This works! Thank you! I also tried the longer method that seems to work.
array _icdvar ICD1-ICD5;
cnticd=0;
do i=1 to 5;
if missing(_icdvar(i)) = 0 then cnticd=cnticd+1;
end;
drop i;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.
Find more tutorials on the SAS Users YouTube channel.