BookmarkSubscribeRSS Feed
GraceStehlin98
Calcite | Level 5

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;

3 REPLIES 3
Astounding
PROC Star

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.

jakarman
Barite | Level 11

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.

---->-- ja karman --<-----
ballardw
Super User

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-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 763 views
  • 0 likes
  • 4 in conversation