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

Hi there,

 

One of my column header was truncated when exporting to RTF, however I guess it should have enough space for the characters.

 

Here is my proc report program


PROC REPORT DATA=_rep NOWD HEADLINE HEADSKIP SPLIT='#' SPACING=1 MISSING ;

  column  _base (" Total#(N = %sysfunc(strip(&BigN))) "  
                  ("&&vis&i" col1 col2 col3 col4 col5 col6 col7 col8 col9 )
                );  


  define _base / style(header)=[just=left asis=on]
                 style(column)=[just=left asis=on cellwidth=9% ] 'Baseline#Result';

  define col1 / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "Negative#n (%)" ;
  define col2 / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "Trace#n (%)" ;
  define col3 / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "+#n (%)" ;
  define col4 / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "++#n (%)" ;
  define col5 / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "+++#n (%)" ;
  define col6 / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "++++#n (%)" ;
  define col7 / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "Positive#n (%)" ;
  define col8 / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "Missing#n (%)" ;
  define col9 / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "Total#n (%)" ;
run;

Here is the output, dummied with all 0.

There should have 4 plus sign in highlighted column, which was defined as col6 in above report program.

 

Coooooo_Lee_0-1643009545305.png

 

Anyone can help to have a look?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Interesting ! It looks like you need pad a blank before '#'

 

ods rtf file='c:\temp\temp.rtf' style=journal bodytitle keepn;

PROC REPORT DATA=sashelp.heart(obs=10) NOWD  SPLIT='#'  MISSING ;

  column  Sex (" Total#(N = %sysfunc(strip(&BigN))) "  
                  ("&&vis&i" AgeAtStart Height Weight Diastolic  Systolic  Smoking  )
                );  


  define Sex/ style(header)=[just=left asis=on]
                 style(column)=[just=left asis=on cellwidth=9% ] 'Baseline#Result';

  define AgeAtStart / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "Negative#n (%)" ;
  define Height / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "Trace#n (%)" ;
  define Weight / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "+ #n (%)" ;
  define Diastolic / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "++ #n (%)" ;
  define Systolic  / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "+++ #n (%)" ;
  define Smoking / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                '++++ #n (%)' ;
run;

ods rtf close;

Ksharp_0-1643028769124.png

 

View solution in original post

5 REPLIES 5
Ksharp
Super User

Interesting ! It looks like you need pad a blank before '#'

 

ods rtf file='c:\temp\temp.rtf' style=journal bodytitle keepn;

PROC REPORT DATA=sashelp.heart(obs=10) NOWD  SPLIT='#'  MISSING ;

  column  Sex (" Total#(N = %sysfunc(strip(&BigN))) "  
                  ("&&vis&i" AgeAtStart Height Weight Diastolic  Systolic  Smoking  )
                );  


  define Sex/ style(header)=[just=left asis=on]
                 style(column)=[just=left asis=on cellwidth=9% ] 'Baseline#Result';

  define AgeAtStart / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "Negative#n (%)" ;
  define Height / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "Trace#n (%)" ;
  define Weight / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "+ #n (%)" ;
  define Diastolic / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "++ #n (%)" ;
  define Systolic  / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                "+++ #n (%)" ;
  define Smoking / style(header)=[just=center asis=on bordertopcolor=black bordertopwidth=0.5pt] 
                style(column)=[vjust=top just=center cellwidth=9.8% ] 
                '++++ #n (%)' ;
run;

ods rtf close;

Ksharp_0-1643028769124.png

 

Coooooo_Lee
Obsidian | Level 7

Interesting! It really works with putting a blank ahead.

But do you know why? 😂

Ksharp
Super User

No. I don't know . Maybe @Cynthia_sas  knows .

Cynthia_sas
SAS Super FREQ

Hi: We don't have data or the full code with the ODS statements, but it appears that this example is trying to use ODS LISTING techniques to do an underscore or underline for the column headers. It looks like the destination of choice is PDF or RTF in this example, based on the screen shot. There is a huge difference between using the LISTING window and expecting 2 underscores or 3 underscores or 4 underscores to take 2, 3 or 4 print positions. A destination that uses a proportional spaced font will NOT use the same space for each letter or font character as a fixed pitch font. For example, take SAS out of the picture and just compare this example of 10 characters on each line: the letter w, hyphen, underscore and the letter i. The example on the left shows the font as Courier New, a fixed pitch font. The example on the right shows the font as Arial, a proportional spaced font.

Cynthia_sas_0-1643297520440.png

This is how the SAME characters are displayed in 2 different fonts. Knowing this, it doesn't make sense to me to try to simulate LISTING behavior with ODS. I would use textdecoration=underline to do underlining:

proc report data=sashelp.class(obs=3) split='#'
     style(header)={textdecoration=underline};
  column name age height weight sex;
  define name / 'Name ' f=$8.;
  define age / 'Age' f=4.;
  define height / 'Height ' f=6.1;
  define weight / 'Weight ' f=6.1;
  define sex / 'Sex ' f=$5.;
run;


Bottom line, LISTING options don't work in ODS. It doesn't surprise me that the headers are funky, that's because you are trying to fit LISTING techniques designed for the listing window into ODS output.

Cynthia

Jianmin
Obsidian | Level 7

Dear All, 

@Cynthia_sas 's answer is irrelevant to understand the problem, and @Ksharp 's solution is a work around solution, a few steps short to understand the problem. Hat off to both of the SAS experts for your efforts.  Thank your @Coooooo_Lee for discovering this problem.  

Apparently, SAS ODS RTF has a coding problem.  It looks like +, -, and = signs are three special characters in this case.  When you have 4 or more these signs alone, SAS will not transcode  them correctly, without a blank space between them and # sign.   (SAS correctly transcode # sign as {\line }, that's correct with RTF specs).   You can use any other characters on the keyboard, or any combination of these 3, you don't need a blank space between them and #.  

This defect of SAS coding should not be surprised.  Remember in SAS own macro language, there are a few special characters and you can't use them directly.   SAS wrote two macro functions: %SUBSTR and %QSUBSTR to handle those special cases.  

 

Jianmin Long

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 5 replies
  • 676 views
  • 0 likes
  • 4 in conversation