☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Calcite | Level 5

Re: Check if the values of multiple columns of one dataset are in multiple columns of another datase

Yes, the values will be 1 or 0 for H3 and H14. We are just identifying the values not counting them in this case. Also, can you explain how will H3 differ from _H3? And will it consider both the conditions?

Thank you so much!

Super User

Re: Check if the values of multiple columns of one dataset are in multiple columns of another datase

``````/*
"Also, can you explain how will H3 differ from _H3? And will it consider both the conditions?"
Here H3/H14 stands for H6 and _H3/_H14 stands for the H7 you mentioned in last post.

"We are just identifying the values not counting them in this case."
If H3 and H14 only have  value 0 or 1,try the following code.
*/
data df1;
input (HAC1 HAC2 HAC3 HAC14 p3 p14) (\$);
cards;
T81500A T800XXA L89003 I2602 A X
T81501A  NaN    L89004 I2692 B Y
T81502A  NaN    NaN    I82401 C NaN
NaN      NaN     NaN   I2699 NaN NaN
;

data df2;
input (DX1 DX2 DX10 proc1 proc2) (\$);
cards;
I639    L89004  I2602 A X
T81500A T81502A R0789 E B
I2692   I2602   Z8541 W Z
G8321   L89004  I10   F Y
;

proc iml;
use df1(keep=HAC:);
read all var _all_ into df1_hac;
close;
use df1(keep=P:);
read all var _all_ into df1_p;
close;
use df2(keep=DX:);
read all var _all_ into df2_dx;
close;
use df2(keep=Proc:);
read all var _all_ into df2_proc;
close;
h1=j(nrow(df2_dx),1,0);
h2=j(nrow(df2_dx),1,0);

h3=j(nrow(df2_dx),1,0);
h14=j(nrow(df2_dx),1,0);

do i=1 to nrow(df2_dx);
h1[i]=sum(element(df2_dx[i,],df1_hac[,1]));
h2[i]=sum(element(df2_dx[i,],df1_hac[,2]));

h3[i] =min( sum(element(df2_dx[i,],df1_hac[,3])) , sum(element(df2_proc[i,],df1_p[,1])) ) ^=  0;
h14[i]=min( sum(element(df2_dx[i,],df1_hac[,4])) , sum(element(df2_proc[i,],df1_p[,2])) ) ^=  0;
end;
create temp var {h1 h2 h3 h14 };
append;
close;
quit;
data want;
merge df2 temp;
run;``````
Discussion stats
• 16 replies
• 1666 views
• 5 likes
• 5 in conversation