BookmarkSubscribeRSS Feed
mick_g
Calcite | Level 5
data:

age_group date enrolled aid
senior 1/5/2011 y y
teen 1/5/2011 y y
child 1/5/2011 y y
infant 1/5/2011 y y
mature 1/5/2011 y n
senior 1/10/2011 y n
teen 1/10/2011 y n

Above is sample data. I need to create an document prefer excel that will first give the sum of each age group and then the total. Second I need to have detail pages for each age group.

I started with a simple proc freq statement but it did not give me the totals. How do I get a total?

For the detail pages in excel should I do a marco or an array. Or is there a much easier way. I know I can do it in proc report but the data needs to be manipulated by the end user which means end user preferes excel.

I also have to put a logo on the top of the report before the title.
1 REPLY 1
Peter_C
Rhodochrosite | Level 12
have you considered proc sort, proc tabulate, followed by proc print, using class/by statement something like :
ods tagsets.excelxp file= '!temp\demo.xml' ;
proc sort data= your_data out= _data_ ;
by age_group ;
run ;
%let ordered = &syslast ;
ods tagsets.excelxp options( sheet_name='summary' ) ;
proc tabulate data= &ordered missing format= 5. ;
class age_group ;
var date ;
table age_group all, n date=' '*( min='from' max='to')*f= mmddyy. ;
run ;
ods tagsets.excelxp options( sheet_name='detail_' ) ;
proc print data= &ordered label noobs ;
by age_group ;
pageby age_group ;
run ;
ods tagsets.excelxp close ;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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