have a question related to the following code.
Temp1, Temp2, Temp3, Temp4 are variables from dataset temp.
Ds1, ds2, ds3, ds4 are variables from the dataset2.
Code is the variable from temp and code has been renamed to _code1 in dataset2.
For a particular records in temp the value of mid=1 and pid =6. It has a single match in dataset 2.
data Temp;
input Code $ mid pid temp1 $ temp2 $ temp3 $ temp4 $;
datalines;
AB 1 6 aaa bbb xxx yyy
;
run;
data Dataset2;
input Code $ ds1 $ ds2 $ ds3 $ ds4 $;
datalines;
AB aaa bbb xxx yyy
;
run;
data two;
set temp;
* Drop temporary variables;
DO i=1 TO xnobs;
SET dataset2 (rename=(code=_code1)) NOBS=xnobs POINT=i;
if code=_code1 then
do;
if mid=1 then
do;
if temp1=ds1 and temp2 = ds2 then
do;
m_match='Y';
output;
end;
end;
if pid =6 then
if temp3 = ds3 and temp4=ds4 then
do;
p_match='Y';
output;
end;
end;
end;
run;
The problem is when I run the below query the output has 2 rows where as I need one row in the output which has both m_match=’Y’ and p_match =’Y’.
Also if by any chance if the output has only one row with either p_match='Y' or m_match='Y', i need to retrieve that as well
It will be great if you can help me with this.
Editing the message to add few more details
Please find the output below
Code
mid
pid
temp1
temp2
temp3
temp4
uni_seq_num
_code1
ds1
ds2
ds3
ds4
m_match
p_match
AB
1
6
aaa
bbb
xxx
yyy
36111
AB
aaa
bbb
xxx
yyy
Y
AB
1
6
aaa
bbb
xxx
yyy
36111
AB
aaa
bbb
xxx
yyy
Y
Y
One thing which i noticed is even though the conditions are matching (temp3=ds3 and temp4=ds4) p_match= set to blank. I am lil confused on this.
Thanks in advance,
Regards,
Sheeba Swaminathan
... View more