BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DME790
Pyrite | Level 9

Hi All,

 

I'm trying to add a percentage from the 'total' in a proc report. I have read a couple of submissions but not making sense to me.

 

My data looks like 9apologies if the test data doesn't work)

data test;
   input ORIGIN_CD TARGET_CD SP04 SP05 SP06 Total;
  datalines;

ABR A 14 12 6 32
ABR B 2 . 1 3
ABR C . 2 1 3
ABR D . 1 . 1
ABR E . . 1 1
ABR F . 1 . 1
ABR G 1 . 1 2
ABR H . 1 . 1
ABR I . . 4 4
ABR J 1 1 1 3
ABR K 1 1 . 2
ABR L . . 1 1
ABR M 1 3 9 13
;
Run;

 

My code is

 

Proc Report data=work.origindestbyqueuecalc;
	by origin_cd;
	Column ORIGIN_CD TARGET_CD SP04 SP05 SP06 Total ;
	define Origin_CD / Display 'Origin';
	Define Target_CD / DISPLAY 'Destination';
	Define SP04 / DISPLAY 'SP2018_04' analysis SUM f=comma9.;
	Define SP05 / DISPLAY 'SP2018_05' analysis SUM f=comma9.;
	Define SP06 / DISPLAY 'SP2018_06' analysis SUM f=comma9.;
	Define Total / DISPLAY 'Total' analysis sum;
	Rbreak after / summarize;
RUN;

which gives me the output of

 

Output2.GIF

and I would like the output to look like the following

Output3.GIF

 

 

Any help appreciated

 

Cheers

 

Dean

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
stat_sas
Ammonite | Level 13

Hi,

 

Please try this.

 

Proc Report data=work.test;
by origin_cd;
Columns ORIGIN_CD TARGET_CD SP04 SP05 SP06 Total Total,(pctsum);
define Origin_CD / Display 'Origin';
Define Target_CD / DISPLAY 'Destination';
Define SP04 / DISPLAY 'SP2018_04' analysis SUM f=comma9.;
Define SP05 / DISPLAY 'SP2018_05' analysis SUM f=comma9.;
Define SP06 / DISPLAY 'SP2018_06' analysis SUM f=comma9.;
Define Total / DISPLAY 'Total' analysis sum;
Define pctsum / 'Percentage' format=percent6. width=8;
Rbreak after / summarize;
RUN;

View solution in original post

2 REPLIES 2
stat_sas
Ammonite | Level 13

Hi,

 

Please try this.

 

Proc Report data=work.test;
by origin_cd;
Columns ORIGIN_CD TARGET_CD SP04 SP05 SP06 Total Total,(pctsum);
define Origin_CD / Display 'Origin';
Define Target_CD / DISPLAY 'Destination';
Define SP04 / DISPLAY 'SP2018_04' analysis SUM f=comma9.;
Define SP05 / DISPLAY 'SP2018_05' analysis SUM f=comma9.;
Define SP06 / DISPLAY 'SP2018_06' analysis SUM f=comma9.;
Define Total / DISPLAY 'Total' analysis sum;
Define pctsum / 'Percentage' format=percent6. width=8;
Rbreak after / summarize;
RUN;

DME790
Pyrite | Level 9

Thanks @stat_sas

 

Is exactly what I was looking for.

 

Cheers

 

Dean

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
  • 2 replies
  • 937 views
  • 2 likes
  • 2 in conversation