Hi,
It's me again the student newbie in SAS.
There are quite a number of issues and answers around this question but I am not familiar with the proc sql yet. I merged two big data sets that I need to analyze but all of of the variables have missing data. I am just wondering if there is a way to delete them in one go using the if-then statements? Below is my code for your reference. Appreciate any assistance! Thank you!
Filename F1 'C:\Users\among\OneDrive\Desktop\Study1_1.txt';
data study1;
infile F1;
infile F1 dsd dlm=',';
infile F1 missover;
input Patient_ID Age State $ Length_of_Stay Total_Charge;
run;
proc print data=study1;
run;
Filename F2 'C:\Users\among\OneDrive\Desktop\Study2_2.txt';
data study2;
infile F2;
infile F2 dsd dlm=',';
infile F2 missover;
input Patient_ID Group $ Test_Score;
run;
proc print data=study2;
run;
proc sort data=study1;
by Patient_ID;
run;
proc sort data=study2;
by Patient_ID;
run;
data final;
merge study1 study2;
by Patient_ID;
run;
proc print data=final;
run;
<successfully merged the data> but a lot of missing observations in all of the variables: Age State Length_of_Stay Total_Charge Group and Test_Score>
I tried
data final_1;
set final;
if Age=. then delete;
if State='' then delete;
if Length_of_Stay=. then delete;
if Total_Change=. then delete;
if Group='' then delete;
If Test_Score=. then delete;
run;
but it didn't work 🙂
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.