I want to create same output with these datalines by merge statment and Proc Sql ....
While doing mergeing I get the note: The Merge statement has one dataset with repeats of By variable...with correct output and in Proc Sql it gives me cartesian product...
is there any alternate way apart from these two..??? Please guide on this ..
data abc;
input pt subj $ trt $;
datalines;
1 111-22 trt
1 111-22 wew
1 111-33 fgd
2 111-22 bdb
2 111-22 fgd
2 111-33 dfg
2 111-33 fsa
2 111-33 bvb
;
run;
data xyz;
input pt subj $ vis ;
datalines;
1 111-22 2
1 111-22 3
1 111-33 2
2 111-22 1
2 111-22 1
2 111-33 2
2 111-33 7
;
run;
proc sort data=abc nodup ;
by pt subj;
run;
proc sort data=xyz nodup;
by pt subj;
run;
data lmn;
merge abc(in=a) xyz(in=b);
by pt subj ;
if a and b;
run;
**********************************Alternate method***********************************;
proc sql;
select distinct abc.*,vis from abc inner join xyz
on abc.pt=xyz.pt and abc.subj=xyz.subj group by abc.pt , abc.subj;
quit;