Hello,
I have the code below and it works, but I would like to add options to "where" and "if" statements below and I keep getting errors.
Note: I already have a lowcase table.
I would also like to the add "emergency_patients" to "where" statement.
/*Identify Patient_Type_ID for in_patients and emergency_patients*/
title 'Proc Print patientid for in)patients';
proc print data=lib.hf_d_patient_type;
where patient_type CONTAINS 'in_patient';
run;
I would like to add another patient_id, "105" to the "if" statement.
/*Restrict Encounters to Inpatients Aged 18 Years or Above*/
data lib.dataB;
set mylib.dataA;
if patient_id=50;
run;
Thanks,
Schtroumfette!
Depends on exactly what you're doing.
In this case (and the next) you can chain your conditions together with an OR
proc print data=lib.hf_d_patient_type; where patient_type CONTAINS 'in_patient' or patient_type contains 'emergency_patient'; run;
There's also an IN operator, if you're looking for exact matches, which is why this approach does not work for the first WHERE statement.
data lib.dataB; set mylib.dataA; if patient_id in (50, 105) ; run;
@Schtroumpfette wrote:
Hello,
I have the code below and it works, but I would like to add options to "where" and "if" statements below and I keep getting errors.
Note: I already have a lowcase table.
I would also like to the add "emergency_patients" to "where" statement.
/*Identify Patient_Type_ID for in_patients and emergency_patients*/
title 'Proc Print patientid for in)patients';
proc print data=lib.hf_d_patient_type;
where patient_type CONTAINS 'in_patient';
run;
I would like to add another patient_id, "105" to the "if" statement.
/*Restrict Encounters to Inpatients Aged 18 Years or Above*/
data lib.dataB;
set mylib.dataA;
if patient_id=50;
run;
Thanks,
Schtroumfette!
Depends on exactly what you're doing.
In this case (and the next) you can chain your conditions together with an OR
proc print data=lib.hf_d_patient_type; where patient_type CONTAINS 'in_patient' or patient_type contains 'emergency_patient'; run;
There's also an IN operator, if you're looking for exact matches, which is why this approach does not work for the first WHERE statement.
data lib.dataB; set mylib.dataA; if patient_id in (50, 105) ; run;
@Schtroumpfette wrote:
Hello,
I have the code below and it works, but I would like to add options to "where" and "if" statements below and I keep getting errors.
Note: I already have a lowcase table.
I would also like to the add "emergency_patients" to "where" statement.
/*Identify Patient_Type_ID for in_patients and emergency_patients*/
title 'Proc Print patientid for in)patients';
proc print data=lib.hf_d_patient_type;
where patient_type CONTAINS 'in_patient';
run;
I would like to add another patient_id, "105" to the "if" statement.
/*Restrict Encounters to Inpatients Aged 18 Years or Above*/
data lib.dataB;
set mylib.dataA;
if patient_id=50;
run;
Thanks,
Schtroumfette!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.