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?
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;
data input_data_current;
set data_file (where = (not missing(id)));
run;
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?
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.