BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
aongkeko
Calcite | Level 5

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 🙂

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star
First step: combine the INFILE statements. For example:

infile F1 dsd missover;

As it stands now, each statement replaces the earlier statement, instead of adding to it.

View solution in original post

1 REPLY 1
Astounding
PROC Star
First step: combine the INFILE statements. For example:

infile F1 dsd missover;

As it stands now, each statement replaces the earlier statement, instead of adding to it.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 652 views
  • 1 like
  • 2 in conversation