hi guys,
I need your help please
So i am supposed to match two datasets and create 3 groups out of this merging.
I have Dataset A with x,y,z and Dataset B with x,y,z,indicator and i merge A and B by x,y
First group would be all leads from A that are in B where Indicator='Y'
Group two -- all leads from A in B where Indicator='N'
and Group three is one+two + remaining from B(non-matching)
So this is how i start with
Data one two three;
merge A(in=ina) B(in=inb);
by x,y;
if ina and inb and indicator='YES' then do; type='A_yes'; output one three;end;
else if ina and inb and indicator='NO' then do; type='A_no;output two three;end;
else do; type='B';output three;end;
i dont get for "three" what i am supposed to get.I know the logic for that group is not right but dont know how to set it up properly
The final group(group three) should have something like:
x y z indicator type
-----------------------------
1 2 3 yes A_yes
2 3 4 yes B
4 5 6 no A_no
2 2 3 no B
............
so combination from one two and the non-matching from B bit not working for me.
i get something like
x y z indicator type
-----------------------------
1 2 3 yes A_yes
. . . . B
4 5 6 no A_no
. . . . B
............
so for the non-matching i only get the "type" values.Rest is missing
Any thoughts please
Us the nesting and ordereing in a more readable way:
if ina and inb then do;
Select ;
When ( indicator='YES) then do;
type='A_yes'; output one three;
end;
When ( indicator='NO' ) then do;
type='A_no;output two three;
end;
Otherwise ; /* is this option possible ?? merged and indicatior not no or yes */
end;
end;
if not ina and inb then do;
type='B'; output three;
end;
Us the nesting and ordereing in a more readable way:
if ina and inb then do;
Select ;
When ( indicator='YES) then do;
type='A_yes'; output one three;
end;
When ( indicator='NO' ) then do;
type='A_no;output two three;
end;
Otherwise ; /* is this option possible ?? merged and indicatior not no or yes */
end;
end;
if not ina and inb then do;
type='B'; output three;
end;
thanks for your response Jaap
I tried with your code but still getting missing values for the third group
I did also ask that question.
Is it possible type has other values as indicated? The place of otherwise....
If there is no join missing an e-file record those values normally coming from wil be missing.
Can you give more details test data what is not going confirm your expectations?
it actually works now,weird.
Client_type is a new variable that i was trying to create with different values for each criteria but thanks for your time and help Jaap.
Cheers
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: