I have this dataset
input store$ type1 type2;
1 1 0
1 0 1
2 0 0
2 0 1
3 1 0
3 0 0;
We need to only filter stores that meet both type1=1 and type2=1. In this case, only store 1 satisfies this condition.
Thanks, it works. But to simplify things, I didn't include other variables in the datalines that are part of the dataset. Is there a way to keep all columns?
It is a good idea to write a thorough problem description. Then we don't have to do "I don't understand"—"Oh thank you for the explanation" — "Here's code that works" — "No it doesn't work for the real problem" dance. Yes of course, there are ways to keep all columns, and I see that @PGStats has provided an alternative, so I won't bother.
I have a follow-up question. Is it possible to create a variable (goal) following the statement "having max(type1)=1 and max(type2)=1" that will be goal=1. Something like if (having statement) then goal=1. I am aware there will only be ones for this newly created variable. But we need this variable so we can then merge with other datasets and then filter rows what will be goal=1.
I did this and it worked, but is this the right way?
create table want as
select * , 1 as goal from test
group by store
having max(type1)=1 and max(type2)=1;
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.