Dear all, Here is an update on what I've got so far: data want;
set have;
array DX (10) dx1-dx10;
do i = 1 to dim(DX);
if DX(i) IN: ('I099','I110','I130','I132','I255','I420','I425','I426','I427','I428',
'I429','I43','I50','P290') then ELX_GRP_1 = 1;else ELX_GRP_1 = 0;
LABEL ELX_GRP_1 = 'Congestive Heart Failure';
end;
run; The code above definitely had sth wrong because all the ELX_GRP_1=0 in all the observations in data "want“”. But I don't know where. If I get rid of the loop, and write: data want;
set have;
if dx1 IN: ('I099','I110','I130','I132','I255','I420','I425','I426','I427','I428',
'I429','I43','I50','P290') then ELX_GRP_1 = 1;else ELX_GRP_1 = 0;
LABEL ELX_GRP_1 = 'Congestive Heart Failure';
run; I would actually get some ELX_GRP_1=1 but that would be the result of searching in dx1, whereas my goal is to search through dx1 to dx10. If either one of the dx variables have the ICD codes of interest, ELX_GRP_1 should be =1. I've tried to change the name of the variables from dx1 to dx2 ...to dx10, like: data want;
set have;
if dx1 IN: ('I099','I110','I130','I132','I255','I420','I425','I426','I427','I428',
'I429','I43','I50','P290') then ELX_GRP_1 = 1;else ELX_GRP_1 = 0;
LABEL ELX_GRP_1 = 'Congestive Heart Failure';
run;
data want;
set want;
if dx2 IN: ('I099','I110','I130','I132','I255','I420','I425','I426','I427','I428',
'I429','I43','I50','P290') then ELX_GRP_1 = 1;else ELX_GRP_1 = 0;
LABEL ELX_GRP_1 = 'Congestive Heart Failure';
run;
etc. But apparently each time the program generate a new ELX_GRP_1 instead of "replace" the value of ELX_GRP_1 the generated by the previous run. So that does not work as well. Can I please get some help on 1) how to write the loop correctly? and 2) how to replace the value of the previously generated variable (instead of generating a whole new variable every time)? Thanks a lot. Ginny Han
... View more