Here is IML code. I believe it would be very fast. data data_x; input (Primary col1 col2) ($); cards; nex1 nex2 nex3 nex2 nex1 nex3 nex3 nex1 nex2 ; run; data data_y; input nex1 nex2 nex3; cards; 1 0 1 0 0 0 3 1 0 1 2 1 0 0 1 ; run; proc iml; use data_x nobs nobs_x; read all var _all_; close; use data_y; read all var _all_; close; want=j(nobs_x,2,.); do i=1 to nobs_x; p=value(Primary[i]); temp_p=(p >= 1); c1=value(col1[i]); temp_c1=(c1 >= 1); want[i,1]=sum((temp_p+temp_c1)=2); c2=value(col2[i]); temp_c2=(c2 >= 1); want[i,2]=sum((temp_p+temp_c2)=2); end; create want from want; append from want; close; quit;
yes, it seems very fast. It works exactly as wanted. I think i need to get used to proc iml. what could be a good starting point? Thanks for all your efforts!
Ha. Here is Rick's blog. You can start with it : http://blogs.sas.com/content/iml/page/41
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.