oK, Let me explain.
I have created a macro where the output of first execution will be an input for next execution to the same macro.
Please find the code in below.
%macro utr(i,bnk_inp);
/****************Cond2*************************/
%if &ii>0 and &UTRNAM =0 and &bennam > 0 %then %do;
DATA rr.UTR_&i(drop=BENE_ACK rename=(BENE_ACK_=BENE_ACK));
SET rr.utr_&i;
%if %substr(BENE_ACK,1,2)="00" %then BENE_ACK_=%substr(BENE_ACK,3);
%else BENE_ACK_=BENE_ACK;
run;
proc sql;
create table rr.first_&i as
select *,(a.narration=b."MBOL REFERENCE NO"n) as indic ,
(a.narration ~= "")as step1,
(b."MBOL REFERENCE NO"n ne "") as utr,
coalesce( a.narration ,b."MBOL REFERENCE NO"n) as fid
from rr.&bnk_inp a full join rr.UTR_&i b on compress(a.narration)=compress(b."MBOL REFERENCE NO"n);
quit;
data rr.ref_match_&i;
set rr.first_&i;
where ((indic =1 and step1=1 ) or ( indic=1 and step1=0 and utr=0 and fid= " "));
run;
proc sql;
create table rr.narration_ref_mismatch_&i as
select * from rr.&bnk_inp where compress(narration) not in ( select narration from rr.ref_match_&i );
quit;
proc sql;
create table rr.sec_c2_&i as
select *,(a.narration=b.bene_ack) as indic ,
(a.narration ne "")as step1,
(b.bene_ack ne "") as utr,
coalesce( a.narration ,b.bene_ack) as fid
from rr.narration_ref_mismatch_&i a full join rr.utr_&i b on a.narration=b.bene_ack;
quit;
data rr.ben_match_&i;
set rr.sec_c2_&i;
where (indic =1 and step1=1);
run;
proc sql;
create table rr.overall_mismatch_&i as
select *,"mismatch" as flag from rr.narration_ref_mismatch_&i where compress(narration) not in ( select narration from rr.ben_match_&i );
quit;
%end;
/***********end of cond2*****************/
/***cond3******/
%else %if &UTRNAM > 0 and &bennam =0 %then %do;
DATA rr.UTR_&i(drop="UTR NUMBER"n rename=("UTR NUMBER_"n="UTR NUMBER"n));
SET rr.utr_&i;
if substr("UTR NUMBER"n,1,2)="00" then "UTR NUMBER_"n=substr("UTR NUMBER"n,3);
else "UTR NUMBER_"n="UTR NUMBER"n;
run;
proc sql;
create table rr.first as
select *,(a.narration=b."MBOL REFERENCE NO"n) as indic ,
(a.narration ~= "")as step1,
(b."MBOL REFERENCE NO"n ne "") as utr,
coalesce( a.narration ,b."MBOL REFERENCE NO"n) as fid
from rr.step1_ a full join rr.utr_&i b on compress(a.narration)=compress(b."MBOL REFERENCE NO"n);
quit;
data rr.ref_match;
set rr.first;
where ((indic =1 and step1=1 ) or ( indic=1 and step1=0 and utr=0 and fid= " "));
run;
proc sql;
create table rr.narration_ref_mismatch as
select * from step1_ where compress(narration) not in ( select narration from rr.ref_match );
run;
PROC SQL;
CREATE TABLE rr.sec_c3 AS
select *,(a.narration=b."UTR NUMBER"n) as indic ,
(a.narration ~= "")as step1,
(b."UTR NUMBER"n ne "") as utr,
coalesce( a.narration ,b."UTR NUMBER"n) as fid
from rr.narration_ref_mismatch a full join rr.utr_&i b on compress(a.narration)=compress(b."UTR NUMBER"n);
quit;
data rr.utr_match;
set rr.sec_c3;
where (indic =1 and step1=1);
run;
proc sql;
create table rr.overall_mismatch as
select * from rr.narration_ref_mismatch where compress(narration) not in ( select narration from rr.utr_match );
run;
data rr.final;
set rr.ref_match rr.utr_match rr.overall_mismatch;
run;
%END;
/*****cond4*********/
%else %if &UTRNAM > 0 and &bennam > 0 %then %do;
DATA rr.UTR_&i(drop="UTR NUMBER"n BENE_ACK rename=("UTR NUMBER_"n="UTR NUMBER"n BENE_ACK_=BENE_ACK));
SET rr.utr_&i;
if substr("UTR NUMBER"n,1,2)="00" then "UTR NUMBER_"n=substr("UTR NUMBER"n,3);
else "UTR NUMBER_"n="UTR NUMBER"n;
if substr(BENE_ACK,1,2)="00" then BENE_ACK_=substr(BENE_ACK,3);
else BENE_ACK_=BENE_ACK;
run;
proc sql;
create table rr.first as
select *,(a.narration=b."MBOL REFERENCE NO"n) as indic ,
(a.narration ~= "")as step1,
(b."MBOL REFERENCE NO"n ne "") as utr,
coalesce( a.narration ,b."MBOL REFERENCE NO"n) as fid
from rr.step1_ a full join rr.utr_&i b on compress(a.narration)=compress(b."MBOL REFERENCE NO"n);
quit;
data rr.ref_match;
set rr.first;
where ((indic =1 and step1=1 ) or ( indic=1 and step1=0 and utr=0 and fid= " "));
run;
proc sql;
create table rr.narration_ref_mismatch as
select * from rr.step1_ where compress(narration) not in ( select narration from rr.ref_match );
run;
PROC SQL;
CREATE TABLE rr.sec_c4 AS
select *,(a.narration=b."UTR NUMBER"n) as indic ,
(a.narration ~= "")as step1,
(b."UTR NUMBER"n ne "") as utr,
coalesce( a.narration ,b."UTR NUMBER"n) as fid
from rr.narration_ref_mismatch a full join rr.utr_&i b on compress(a.narration)=compress(b."UTR NUMBER"n);
quit;
data rr.utr_match;
set rr.sec_c4;
where (indic =1 and step1=1);
run;
proc sql;
create table rr.UTR_ref_mismatch as
select * from rr.narration_ref_mismatch where compress(narration) not in ( select narration from rr.utr_match );
run;
proc sql;
create table rr.third_c4 as
select *,(a.narration=b.bene_ack) as indic ,
(a.narration ne "")as step1,
(b.bene_ack ne "") as utr,
coalesce( a.narration ,b.bene_ack) as fid
from rr.UTR_ref_mismatch a full join rr.utr_&i b on a.narration=b.bene_ack;
quit;
data rr.ben_match;
set rr.third_c4;
where (indic =1 and step1=1);
run;
proc sql;
create table rr.overall_mismatch as
select *,"mismatch" as flag from rr.UTR_ref_mismatch where compress(narration) not in ( select narration from rr.ben_match );
run;
data rr.final;
set rr.ref_match rr.utr_match rr.ben_match rr.overall_mismatch;
run;
%end;
%mend ;
%macro uu;
%IF &II > 0 and &FF>0 %THEN %DO;
%UTR(1,step1_);
%UTR(2,overall_mismatch_1);
%END;
%MEND;
%UU
but it still throws errors , even though i am getting correct output .Please look into the issue once
... View more