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!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.