Desktop productivity for business analysts and programmers

why the observations were not sent to output?

Reply
Occasional Contributor
Posts: 5

why the observations were not sent to output?

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;

Attachment
Respected Advisor
Posts: 4,956

Re: why the observations were not sent to output?

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.

Valued Guide
Posts: 3,206

Re: why the observations were not sent to output?

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 --<-----
Grand Advisor
Posts: 10,196

Re: why the observations were not sent to output?

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)

Ask a Question
Discussion stats
  • 3 replies
  • 224 views
  • 0 likes
  • 4 in conversation