Help using Base SAS procedures

Proc Report with a Percentage in a 'rbreak after /summarize' row.

Reply
Contributor
Posts: 25

Proc Report with a Percentage in a 'rbreak after /summarize' row.

The code below reproduces where I'm at.

Instead of the summary line below each yearmonth (period) value, I want it to be a percentage of the ABM and CPDW summary lines from above.

For example in period 201412-->ABM the totals column is 31,456,193. The CPDW value is 37,993,614.

I want the summary line to show .8279 which is 31456193 / 37993614.

I'd like this for linen1 and linen2 as well.

How do I do that?

My code so far.

data rota_srcs;

  input yearmonth $ src $ road $ linen1   linen2 ;

  datalines;

201412 ABM  KCSM 918258   8331433

201412 ABM  KCSR 13952264 8254238

201412 CPDW KCS  16023991 10130691

201412 CPDW KCSM 1089910  10749022

201501 ABM  KCSM 1294123  10645353

201501 ABM  KCSR 16162258 10387192

201501 CPDW KCS  16168013 10401576

201501 CPDW KCSM 1295325  10653633

run;


proc sort data = rota_srcs;

  by yearmonth;

run;

proc report data = rota_srcs nowd headskip headline split = '*'

  style(summary)=[background=yellow font_weight=bold];

  by yearmonth;

    column yearmonth src road linen1-linen2 totals pct_dif;

  define yearmonth / 'period' group;

  define src /order;

  define road /order;

  define linen1 /analysis;

  define linen2 /analysis;

  define totals    /computed format = comma12.;

  define pct_dif   /computed noprint 'totals';

   break after src  / summarize;

   break after yearmonth / ;

   rbreak after / summarize dol;

     compute totals;

       totals = sum(linen1.sum,linen2.sum);

     endcomp;

run;

Ask a Question
Discussion stats
  • 0 replies
  • 149 views
  • 0 likes
  • 1 in conversation