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?
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.