Exploring, predicting and reporting with SAS Visual Analytics and SAS Visual Statistics

Quarter wise Calculation

Reply
Contributor
Posts: 29

Quarter wise Calculation

Need a help to get output like my sample output..can anyone help me out..thanks in advance


Sample output.png
Super Contributor
Posts: 282

Re: Quarter wise Calculation

Hi,

I made some assumptions in coming up with the following:

data have;

  infile datalines dlm=',';

  input dt date9. amount;

  datalines;

30APR2013,100

31MAY2013,200

30JUN2013,300

31JUL2013,100

31AUG2013,200

30SEP2013,300

31OCT2013,100

30NOV2013,200

31DEC2013,300

31JAN2014,100

28FEB2014,200

31MAR2014,300

;

data want;

  file 'your-file-path' dlm=',';

  set have end=lastrec;

  put dt monname9. amount;

  subtotal+amount;

  grandtotal+amount;

  monthcount+1;

  if mod(monthcount,3)=0 then

  do;

    quarter=cat("QTR ",ifn(qtr(dt)=1,4,qtr(dt)-1));

    put quarter subtotal;

    if lastrec then

      months="Grandtotal";

    else

      months=cat(monthcount," months");

    put months grandtotal;

    subtotal=0;

  end;

run;

If you need something else then please supply more information, such as input data.

Regards,

Amir.

Ask a Question
Discussion stats
  • 1 reply
  • 294 views
  • 0 likes
  • 2 in conversation