BookmarkSubscribeRSS Feed
a_zacMD
Obsidian | Level 7

Hi there, I am using SAS Enterprise Guide. 

I am aware there are ways to keep or drop variables when opening new files. For example: 

 

data input_data_current;

set data_file (drop=var1 var2 var3); 

run;

 

And I am aware that I can remove rows with missing IDs but can I remove those rows that are missing IDs when I initially open the file? 

3 REPLIES 3
ballardw
Super User

Are you looking for something like this?

data want;
   set data_file ; 
   where not missing(id);
run;

Not quite sure what "initially open the file" actually means in your context.

Most procedures will honor the where statement as well and the few that might not would honor a data set option so you may not need to create a new data set.

Proc print data=somedatesetname;
   where not missing(id);
run;

/* or data set option*/
Proc print data=somedatasetname (where=( not missing(id)));
run;
PaigeMiller
Diamond | Level 26
data input_data_current;
    set data_file (where = (not missing(id))); 
run;
--
Paige Miller
Reeza
Super User

You can use a WHERE statement or data set option to filter your data. A WHERE statement or the data set option filters can be used in almost every proc in SAS.

 

Data set option:

data input_data_current;
set data_file(drop = var1 var2 var3 where=(not missing(ID)));
run;

WHERE statement

data input_data_current;
set data_file(drop = var1 var2 var3);

where not missing(ID);
run;

Just a quick comment on terminology "Opening files" could be interpreted in several different ways so it's a very ambiguous term.

 

 


@a_zacMD wrote:

Hi there, I am using SAS Enterprise Guide. 

I am aware there are ways to keep or drop variables when opening new files. For example: 

 

data input_data_current;

set data_file (drop=var1 var2 var3); 

run;

 

And I am aware that I can remove rows with missing IDs but can I remove those rows that are missing IDs when I initially open the file? 


 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 854 views
  • 1 like
  • 4 in conversation