Hi all, I'm new to SAS University Edition and I would greatly appreciate your help. I'm having difficulty finding a solution to a problem I have with two dimensional arrays. I am trying to determine how many times particular medications were given in the Emergency Department (ED) and whether they were given in the ED, given at ED discharge, or both. The dataset I am working with has information regarding up to 8 medications given during a patient visit to the ED (med1-med8). Each medication is identified by multiple 5-digit codes. For instance, the medication tramadol can be coded as 95050, 96041, 00319, or 08329. This is coded as a character variable. Furthermore, variables gpmed1-gpmed8 describe if the corresponding medication in med1-med8 was given in the ED (1), as a prescription at discharge (2), both (3) or blank/NA (-7,-9,8,9). So for instance, if med1 = 95050 and gamed = 2, then Tramadol was given at ED discharge for that particular visit. This is the SAS code I used to determine frequency for a particular medication, Tramadol in this example: data example.working;
set example.working;
array meds(8) med1-med8;
array gpmeds(8) gpmed1-gpmed8;
do i = 1 to 8;
if meds(i) in ('95050','96041','00001','03319','08329')
and gpmeds(i) = 1 then Tramadol = 1;
if meds(i) in ('95050','96041','00001','03319','08329')
and gpmeds(i) = 2 then Tramadol = 2;
if meds(i) in ('95050','96041','00001','03319','08329')
and gpmeds(i) = 3 then Tramadol = 3;
if meds(i) in ('95050','96041','00001','03319','08329')
and gpmeds(i) in (-7,-9,8,9) then Tramadol = 4;
if meds(i) in ('95050','96041','00001','03319','08329')
and gpmeds(i) in ( . ) then Tramadol = 5;
end;
run;
proc freq data=example.working;
tables Tramadol;
run; This gives me the frequencies of Tramadol being given in the ED, at discharge, or both. The issue that I found (after looking at the dataset manually) is that sometimes a medication is coded with a different 5 digit ID code for the same patient visit (or observation). For example, one instance of the medication (med1) would indicate that was given in the ED (gpmed1 = 1) and another instance of the medication (med5) using a different ID code would indicate it was given at discharge (gpmed5=2). The code above would then register Tramadol as if it was given only at discharge rather than given at both. So, some medications are coded twice with different IDs for the same observation when they really should be coded once with gpmed=3, indicating it was given both in the ED and at discharge. My question is how could I modify my code so it finds and takes into account the same medications that were coded with different IDs for the same observation and truly indicate if it was given in the ED, at discharge, or both. Thank you so much in advance for your help.
... View more