BookmarkSubscribeRSS Feed
avinesh
Fluorite | Level 6

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


Sample output.png
1 REPLY 1
Amir
Ammonite | Level 13

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.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 844 views
  • 0 likes
  • 2 in conversation