BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
sas_user
Obsidian | Level 7

Hi,

I am new to SAS ODA. I am trying to create a RTF report using ODS and PROC REPORT Procedure. Report is being created however some options are not working from below code.

 

Code:

/* Reporting */
 
ODS listing close;
ODS RTF body = "xxx.rtf";
 
 
proc report data = tab_all1 headline headskip nowd center split = "^";
column mainord seq label trt1 trt2 trt3 trt99;
 
define mainord / order order = data noprint;
define seq / order order = data noprint;
 
define label / width = 5 "Characteristics" ;
define trt1 /  width = 2 center "Xanomeline Low Dose^(N=XX)^n (%)" ;
define trt2 /  width = 2 center "Xanomeline High Dose^(N=XX)^n (%)" ;
define trt3 /  width = 2 center "Placebo^(N=XX)^n (%)" ;
define trt99 /  width = 2 center "Total Population^(N=XX)^n (%)" ;
 
break after mainord/skip;
run;
 
ODS RTF close;
ODS listing;
 
sas_user_0-1752402147018.png

 


 

Issue 1.  Break after statement does not produce break, neither is SAS result window output nor in RTF file. 

Issue 2. Input dataset has some Label variable values with 2 leading spaces as highlighted in blue, but those spaces are striped in output window and RTF both.

Issue 3. I am giving CENTER option for center justification in PROC REPORT statement. But all variables are left aligned. When i explicitly define CENTER justification in each define statement , then it works.

 

I am aware SAS ODA has some limitations, are these issues because of that, or am i making some mistake in syntax? 

Many thanks in advance. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

It is best practice to provide example data when wanting to get specific output. Sometimes the data needs to change and without an example data set is hard to tell what may be needed. Best is to provide a data step to create such data.

 

The stripping of leading spaces is default behavior in almost all output. You can try using the style override of ASIS to prevent that.

data example;
 text = '  sometext';
run;

/* default behavior*/
proc report data=example;
   columns text;
   define text/order;
run;
/* override the default behavior with the style setting ASIS*/
proc report data=example;
   columns text;
   define text/order style=[asis=on];
run;

 

Can't test the behavior of BREAK without data. Note that the SKIP option of Break only applies in the ODS LISTING destination an will have no effect in another destinations. The default output window is likely to be ODS HTML and will not show such. Also ODS RTF will not as it is not the LISTING (which means very plain text) either. 

 

You don't show any code for how you attempted to center the results but since you show WIDTH option I suspect that you attempted the CENTER option. Both of those option also only apply to the ODS LISTING destination.

In other than LISTING style elements are used to control such things as width of cells or other properties. To create a 2 inch wide box and center the output

proc report data=example;
   columns text;
   define text/order style=[cellwidth=2in just=c];
run;

Just stands for justification.

The online help for Proc Report has several examples of using ODS style settings as well as responses to questions on this forum.

The style settings let you control things like the background color, font properties like family, size, color, borders of the cells, space around the displayed values and many other things. 

View solution in original post

4 REPLIES 4
ballardw
Super User

It is best practice to provide example data when wanting to get specific output. Sometimes the data needs to change and without an example data set is hard to tell what may be needed. Best is to provide a data step to create such data.

 

The stripping of leading spaces is default behavior in almost all output. You can try using the style override of ASIS to prevent that.

data example;
 text = '  sometext';
run;

/* default behavior*/
proc report data=example;
   columns text;
   define text/order;
run;
/* override the default behavior with the style setting ASIS*/
proc report data=example;
   columns text;
   define text/order style=[asis=on];
run;

 

Can't test the behavior of BREAK without data. Note that the SKIP option of Break only applies in the ODS LISTING destination an will have no effect in another destinations. The default output window is likely to be ODS HTML and will not show such. Also ODS RTF will not as it is not the LISTING (which means very plain text) either. 

 

You don't show any code for how you attempted to center the results but since you show WIDTH option I suspect that you attempted the CENTER option. Both of those option also only apply to the ODS LISTING destination.

In other than LISTING style elements are used to control such things as width of cells or other properties. To create a 2 inch wide box and center the output

proc report data=example;
   columns text;
   define text/order style=[cellwidth=2in just=c];
run;

Just stands for justification.

The online help for Proc Report has several examples of using ODS style settings as well as responses to questions on this forum.

The style settings let you control things like the background color, font properties like family, size, color, borders of the cells, space around the displayed values and many other things. 

sas_user
Obsidian | Level 7
Thank you.
I understood mistakes i made and corrected them.
Cynthia_sas
Diamond | Level 26
Hi:
As previously mentioned, some of the options specified in your code are LISTING only options and are ignored by ODS RTF and other ODS destinations. (HEADLINE, HEADSKIP, SKIP, etc -- all these and others are well documented) . To impact the RTF output, the best option is to use STYLE= overrides that are supported by ODS RTF, ODS PDF and ODS HTML. There have been many previous posts about using STYLE= overrides. And, as previously explained, without data, no one can test or tweak your code.
Cynthia
sas_user
Obsidian | Level 7
Thank you.
I understood the mistakes i made and corrected them.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4 replies
  • 900 views
  • 3 likes
  • 3 in conversation