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.
Anyone can help to have a look?
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;
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;
Interesting! It really works with putting a blank ahead.
But do you know why? 😂
No. I don't know . Maybe @Cynthia_sas knows .
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.
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
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
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.