BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ksharp
Super User
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;


munitech4u
Quartz | Level 8

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!

Ksharp
Super User
Ha. Here is Rick's blog. You can start with it :


http://blogs.sas.com/content/iml/page/41

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 17 replies
  • 6291 views
  • 2 likes
  • 5 in conversation