ODS and Base Reporting

Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mattmm
Fluorite | Level 6

Hello,

 

I am trying to add style elements to the by line of my PDF file output. As of now it is putting the variable, an '=' sign, and the output. I want to control the style (font, label name, etc.) as well as the output (remove the '='). I have tried several ways and read the SAS documentation on ODS Style and Proc Print, but I'm unable to come across a solution. Is this possible or should I try another route to achieve this?

 

I've messed around with using a title statement as a placeholder of var2, but the by line separates the output by the second variable (var2), and nest a table under that unique variable so it gets messy trying to make that work.

 

Sample Code:

ods pdf close;
options orientation=landscape nodate number nocenter papersize=legal; ods pdf file="&path&name .pdf" style=my_style; title1 justify=left font=arial 'Left Title' justify=right "Right Title"; Proc print data=have rows=page split='*' style(header obs obsheader)={just=center font_face=arial fontsize=2.2} obs="Item"; by var1 var2; /*this is what I want to control the style of*/ Var var3 var4/style(data)=[background=white just=center font_face=arial fontsize=2]; format var3 var4 best7.2; label var3= 'The Third Variable' var4= 'The Fourth Variable'; run; ods pdf close; run;
Sample Output:
mock_output.jpg

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
I don't think STYLE will allow to change the structure of the BY line, specifically the Equals sign. At least not without messing around with templates.
I would probably recommend using a custom title statement instead and using #BYVAL/#BYVAR options instead.

Note the usage of multiple TITLE statements in this example:
https://support.sas.com/resources/papers/proceedings/proceedings/sugi23/Coders/p75.pdf

View solution in original post

5 REPLIES 5
Reeza
Super User
I don't think STYLE will allow to change the structure of the BY line, specifically the Equals sign. At least not without messing around with templates.
I would probably recommend using a custom title statement instead and using #BYVAL/#BYVAR options instead.

Note the usage of multiple TITLE statements in this example:
https://support.sas.com/resources/papers/proceedings/proceedings/sugi23/Coders/p75.pdf
mattmm
Fluorite | Level 6

This is exactly what I needed, thank you very much.

Reeza
Super User

FYI - I've moved this post to the ODS Reporting section so hopefully you get a better response here. 

Ksharp
Super User

Follow as Reeza said.

 

data have(index=(x=(sex age)));
 set sashelp.class;
 if age in ( 12 14 15);
run;


options nobyline;
ods pdf file="c:\temp\temp.pdf" style=meadow;
title1 justify=left font=arial 'Left Title' justify=right "Right Title";
title2 j=left color=red bcolor=green "#byvar1 = #byval1 || #byvar2 = #byval2";

Proc print data=have rows=page split='*' style(header obs obsheader)={just=center font_face=arial fontsize=2.2} obs="Item";
 by sex age; /*this is what I want to control the style of*/
 Var weight height/style(data)=[background=white just=center font_face=arial fontsize=2];
run;

ods pdf close;

Ksharp_0-1641901511003.png

 

mattmm
Fluorite | Level 6

I followed what Reeza said and that is the solution. Great to see it here in practice as the visual showed me what to apply. Thank you for your help.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 5 replies
  • 1482 views
  • 5 likes
  • 3 in conversation