Hello,
My data looks something like this:
var1 var2
1 2
3 3
1 3
I need to keep only the data points that match, such as when var1 and var2 both have a value of 3, and I can get rid of the rest of the data. How could I do this?
data want;
set have;
if var1=var2;
run;
@sdevenny wrote:
Hello,
My data looks something like this:
var1 var2
1 2
3 3
1 3
I need to keep only the data points that match, such as when var1 and var2 both have a value of 3, and I can get rid of the rest of the data. How could I do this?
data want;
set have;
if var1=var2;
run;
@sdevenny wrote:
Hello,
My data looks something like this:
var1 var2
1 2
3 3
1 3
I need to keep only the data points that match, such as when var1 and var2 both have a value of 3, and I can get rid of the rest of the data. How could I do this?
Since all values for the condition are contained in the incoming dataset, you can use WHERE in its different forms as statement, dataset option or SQL clause:
data want;
set have;
where var1 = var2;
run;
data want;
set have (where=(var1 = var2));
run;
proc sql;
create table want as
select *
from have
where var1 = var2
;
quit;
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.