Hello,
I have a group of variables that describe what procedure a patient got (up to 15 procedures) that are ICD-9 codes in strings (e.g. "6701") that are PR1, PR2.....PR15.
Another group of variables are the day on which those procedures happen (e.g. 1, 2, 5, 10...) that are PRDAY1, PRDAY2....PRDAY15.
How do I match up what day a SPECIFIC procedure happened? e.g. I need a variable that tells me that patient got procedure 6701 (Surgery) on day 6.
These are how the procedure variables have been labeled thus far:
Data Inpatients;
array PR {15} PR1-15;
do k=1 to 15;
if PR{k] = '6701] then Surgery =1
etc.
end;
Thank you!
I'm using SAS 9
What I've tried, not sure if this makes sense:
Data Dataset;
set Dataset;
array PR {15} PR1-15;
do k=1 to 15;
array PRDAY {15} PRday1-15;
do k=1 to 15; if PR{k} = '6701' then Surgeryvar=PRday{k};
run;
You're on the right track. One thing that stands out as needing to be changed: how you specify a list of variables. The right way:
array PR {15} PR1-PR15;
array PRDAY {15} PRday1-PRday15;
It's possible that this is the only change you need to make. Try it and see what you get.
Also, consider what you would like to do if the patient had two surgeries, and you would need two variables to hold the dates.
OK, here's a step in that direction:
Data want;
set have;
array PR {15} PR1-PR15;
array PRDAY {15} PRday1-PRday15;
do k=1 to 15;
if PR{k} = '6701' then do;
if surgeryvar1 = . then Surgeryvar1=PRday{k};
else Surveryvar2=PRday{k};
end;
end;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.