Hi, I am having trouble figuring out how to program a set of conditions. Below is the code and conditions and where i need help. I have attached a sas dataset 'test' with 5 variables - Time1, Time2, Creat_cat, PT_cat and PF_ratio. I am trying to create a new variable 'Severity' with the following conditions. Thank you in advance.
Data test;
if Creat_cat ='Greater than 1.8' and PT_cat = '<300'
/* (for MORE THAN 48 hours at anytime between Time1 and Time2)- I need help here*/
then Severity = 'severe';
if Creat_cat ='Greater than 1.8' and PT_cat = '<300'
/* (for LESS THAN 48 hours at anytime between Time1 and Time2)- I need help here*/
then Severity = 'Moderate';
else Severity = 'Mild';
run;
for MORE THAN 48 hours at anytime between Time1 and Time2
I don't understand what this means. Do you mean that Time1 and Time2 are more than 48 hours apart? Or do you mean something else? If you mean something else, please give us concrete examples (plural) of what you mean.
Thank you for your help. I have updated the dataset for clarity.
Each record is for a specific timestamp , RECORDED_DATE
ID is the record number (unique to each patient)
enc is the hospital encounter number for a particular visit
Time1 is the admission time
Time2 is the discharge time
Creat_cat is creatinine as a dichotomous variable (<1.8 and >1.8)
PT_cat is a dichotomous variable (<300 and >=300)
If a patient (ID) has Creat_cat >1.8 or PT_cat <300 for more than 48hours at anytime between Time1 and Time2 (during admission), I would like to classify them as 'severe'.
If a patient (ID) has Creat_cat >1.8 or PT_cat <300 for less than 48hours at anytime between Time1 and Time2(during admission), I would like to classify them as 'moderate'.
If a patient (ID) does not satisfy either condition (of time), I would like to classify them as mild.
How is this calculation of "for more than 48 hours" done? Please give concrete examples. Please don't make me have to repeatedly ask for information.
I don't know what this means relative to the data provided. I have asked for the meaning of this 48 hour interval, and how it is calculated from the data, and you haven't answered. If you can't show us a concrete example (even if it is made up), then I don't see how to proceed.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.