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-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!

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.

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
  • 1 reply
  • 765 views
  • 0 likes
  • 2 in conversation