08-10-2015 03:38 PM
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.
08-10-2015 04:14 PM
in a data step:
numvalid = n( of ICD1-icd5);
The function NMISS with the same basic syntax would give the missing per record.
08-10-2015 04:49 PM
for character variables you would use the function cmiss().
For count of not missing:
valid = 5 - cmiss(of icd1-icd5);
or for count of missing:
valid = cmiss(of icd1-icd5);
08-10-2015 05:55 PM
This works! Thank you! I also tried the longer method that seems to work.
array _icdvar ICD1-ICD5;
do i=1 to 5;
if missing(_icdvar(i)) = 0 then cnticd=cnticd+1;