Can someone help?
the do loop is in macro procedure.
without %do ...%end, the output was genrated.
when i add %do...%end..., the log shows the oberservations were created. but the output were not sent into the table.
%macro rundetection;
%do i=0 %to &ndays;
%let begrange=%eval((startdate+&i)-(&lookbackperiod-1));
%let endrange=%eval(&startdate +&i);
data fsc_cash_flow_stg2_alert;
set fsc_cash_flow_stg2_count_ck1 end=eor;
where datepart(tran_dt)>=&begrange
and datepart(tran_dt)<=&endrange;
run;
proc sort data=fsc_cash_flow_stg2_alert;
by party_number;
run;
data fsc_cash_flow_stg2_alert1;
set fsc_cash_flow_stg2_alert;
by party_number;
if first.party_number then
do;
totaldebitamount=0;
totaldebitcount=0;
totalcredtiamount=0;
totalcreditcount=0;
totalcount=0;
end;
if upcase(transaction_cdi_desc)='debit' then
do;
totaldebitamount+tran_amount;
totaldebitcount+1;
end;
else do;
totalcreditamount+tran_amount;
totalcreditcount+1;
end;
if last.party_number and (totaldebitcount+totalcreditcount)>=3 then
output;
run;
%end;
%mend;
%rundetection;
Not a complete solution by any means, but here are two issues you will need to address.
(1) Your formula for beginning of a range is missing an ampersand. Using %EVAL((startdate should be generating an error.
(2) Even without a macro loop, you are getting the wrong answer if you look for the UPCASE function to return 'debit'. It could return 'DEBIT', but it could never return 'debit'.
Good luck.
Your did program marvelous for 30 times. Every step a new selection on the same datasets and a the end you have selected that much (dropped records) not keeping any data.
There is no error. Perhaps it did not what you wanted, it did what you have coded.
Also you might consider changing this:
data fsc_cash_flow_stg2_alert1;
to
data fsc_cash_flow_stg2_alert&i;
otherwise each loop overwrites the previous version of the data set and you'll only get output for the value of &ndays. (which isn't defined where the value comes from, so that could be another place to look for issues)
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.