Hi....is it possible to use the #byval feature in the header when creating an rtf file? The following code works but instead of having a title I would like the title as a header on each table....Thanks.
ods listing close;
options nodate;
title;
options nobyline;
ods rtf FILE="%sysfunc(pathname(project))\report.rtf";
title "#byval(monthnum) &year";
proc report data=summary center nowd
style(report)=[font=(Arial, 8pt)]
style(column)=[font=(Arial, 8pt) cellheight=1in cellwidth=1in]
style(header)=[font=(Arial, 10pt) font_weight=bold]
split='*';
by monthnum;
format monthnum nlstrmon.;
column ((weeknum Sun Mon Tue Wed Thu Fri Sat));
define weeknum / group order=internal noprint;
compute Sun;
call define(_col_, "style","style={background=lightgrey}");
endcomp;
compute Sat;
call define(_col_, "style","style={background=lightgrey}");
endcomp;
run;
ods rtf close;
options byline;
title;
Hi:
You can get something like this, using PROC REPORT and the PAGE option -- use it with or without BY variables -- if you don't want the title, then take out the BY statement and take out the TITLE.
But you will need to understand the COMPUTE BEFORE and using GROUP or ORDER variables as "page" variables.
cynthia
with this code using SASHELP.PRDSALE (you'll have to adapt the code to your data):
proc means data=sashelp.prdsale nway n sum;
class year quarter country region;
var actual;
output out=work.mnout n=cnt sum=actsum mean=actmean;
run;
proc print data=mnout;
run;
ods _all_ close;
proc sort data=mnout;
by year quarter country region;
run;
options nobyline;
ods rtf FILE="c:\temp\use_page_report.rtf";
title "Title: #byval1 and Qtr #byval2";
proc report data=mnout center nowd
style(report)=[font=(Arial, 8pt)]
style(column)=[font=(Arial, 8pt)]
style(lines)=Header{font=(Arial, 10pt) font_weight=bold}
style(header)=[font=(Arial, 10pt) font_weight=bold]
split='*';
by year quarter;
column (year quarter country region cnt actsum actmean);
define year / group page noprint;
define quarter / group page noprint;
define country / order;
define region / order;
define cnt / 'Count';
define actsum / sum;
define actmean / 'Mean';
break before year / page;
compute before _page_;
pgstr = catx(' ','Year:',year,'--', 'Quarter',quarter);
line pgstr $varying100.;
endcomp;
run;
ods rtf close;
options byline;
title;
Hi:
You can get something like this, using PROC REPORT and the PAGE option -- use it with or without BY variables -- if you don't want the title, then take out the BY statement and take out the TITLE.
But you will need to understand the COMPUTE BEFORE and using GROUP or ORDER variables as "page" variables.
cynthia
with this code using SASHELP.PRDSALE (you'll have to adapt the code to your data):
proc means data=sashelp.prdsale nway n sum;
class year quarter country region;
var actual;
output out=work.mnout n=cnt sum=actsum mean=actmean;
run;
proc print data=mnout;
run;
ods _all_ close;
proc sort data=mnout;
by year quarter country region;
run;
options nobyline;
ods rtf FILE="c:\temp\use_page_report.rtf";
title "Title: #byval1 and Qtr #byval2";
proc report data=mnout center nowd
style(report)=[font=(Arial, 8pt)]
style(column)=[font=(Arial, 8pt)]
style(lines)=Header{font=(Arial, 10pt) font_weight=bold}
style(header)=[font=(Arial, 10pt) font_weight=bold]
split='*';
by year quarter;
column (year quarter country region cnt actsum actmean);
define year / group page noprint;
define quarter / group page noprint;
define country / order;
define region / order;
define cnt / 'Count';
define actsum / sum;
define actmean / 'Mean';
break before year / page;
compute before _page_;
pgstr = catx(' ','Year:',year,'--', 'Quarter',quarter);
line pgstr $varying100.;
endcomp;
run;
ods rtf close;
options byline;
title;
How would you do this if you wanted to see the month name?
It should be easier than this. Please support the Ballot idea:
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.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.