Hi, Based on my understanding about your requirement i have designed one macro for matching the observations and based on that it will calculate the percentages respectively... data sample; input sr_no AB001A AB0002A; cards; 1 15 25 2 15 25 3 25 84 4 25 84 5 08 09 6 10 12 7 10 12 8 48 15 ; %macro match; proc contents data = sample out = test(keep = name) noprint; run; proc sql noprint; select name into :list separated by ' ' from test where name ^? "sr_no"; select count(name) into :count from test where name ^? "sr_no"; quit; %let count = &count.; data compare(drop = _temp:); set sample; %do i = 1 %to &count.; _temp&i. = dif(%scan(&list.,&i.)); if _temp&i. = 0 then var&i. = 1; else var&i. = 0; %end; run; proc sql noprint; select %do i = 1 %to %eval(&count.-1); sum(%scan(&list.,&i.)), %end; sum(%scan(&list.,&count.)) into %do i = 1 %to %eval(&count.-1); :%scan(&list.,&i.)_sum, %end; :%scan(&list.,&count.)_sum from compare where %do i = 1 %to %eval(&count.-1); var&i. = 1 or %end; var&count. = 1; quit; proc sql; create table compare as select *, %do i = 1 %to %eval(&count.-1); sum(%scan(&list.,&i.)) as total_%scan(&list.,&i.), %end; sum(%scan(&list.,&count.)) as total_%scan(&list.,&count.) from compare; quit; data final(drop = total: sum:); set compare; %do i = 1 %to &count.; sum&i. = symget("%scan(&list.,&i.)_sum"); %scan(&list.,&i.)_percent = sum&i./total_%scan(&list.,&i.)*100; %end; run; %mend; options mlogic mprint; %match; Hope this macro help you to achive your output using SAS... -Urvish
... View more