Data visualization with SAS programming

Intervening spaces in a character variable removed in ODS output

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Intervening spaces in a character variable removed in ODS output

I'm trying to create a "caterpillar plot" using ODS PDF.  The X variable is 1 long character variable, consisting of several concatenated variables. In the basic SAS output, the concatenated variables (within the larger X variable) are aligned just how I want them, but they lose that alignment in the PDF output. The alignment ia also off in the ODS HTML output - it looks like extra spaces (which I need to retain) are being removed between the concatenated variables.  Does anyone know what could cause the extra spaces to be removed in ODS?

I'm relatively new to modifying this type of graph output in SAS, so I'd appreciate any help!


Accepted Solutions
Solution
‎07-26-2012 11:48 AM
Grand Advisor
Posts: 10,196

Re: Intervening spaces in a character variable removed in ODS output

Font

The traditional output is using SAS Monospace. The HTM and PDF are using proportional fonts. You will need to use a style for HTML and PDF that use a non-proportional font to align as you would like. You may need to make a custom style using Courier or something similar. At least that's a start.

View solution in original post


All Replies
SAS Employee
Posts: 967

Re: Intervening spaces in a character variable removed in ODS output

Which proc are you using?

Can you post an example (maybe a screen-capture) of the output you're seeing?

(the good output, and the bad output)

New Contributor
Posts: 3

Re: Intervening spaces in a character variable removed in ODS output

Sure - see attached.

Basic SAS output – This is the alignment I want.  I’ve formatted the concatenated variables so that hospital name is left-aligned and the numbers are right-aligned.  The sum of the lengths of the concatenated variables (plus spaces between) is exactly the length of the new “hosnamenew” variable. 

ODS HTML output after a simple proc print – The intervening spaces appear to be removed, and the variable is now left-aligned.

ODS PDF output after proc template and proc sgrender – Some of the intervening spaces are now removed, and the variable appears to be right-aligned.  Differing lengths in the 5th column are causing misalignment to the left, even though the formatting of “hosnamenew” hasn’t changed.

Solution
‎07-26-2012 11:48 AM
Grand Advisor
Posts: 10,196

Re: Intervening spaces in a character variable removed in ODS output

Font

The traditional output is using SAS Monospace. The HTM and PDF are using proportional fonts. You will need to use a style for HTML and PDF that use a non-proportional font to align as you would like. You may need to make a custom style using Courier or something similar. At least that's a start.

New Contributor
Posts: 3

Re: Intervening spaces in a character variable removed in ODS output

Thank you!!!  I definitely wasn't anticipating such a simple solution. :-)

SAS Super FREQ
Posts: 1,078

Re: Intervening spaces in a character variable removed in ODS output

This looks like a Forest plot.  Here is an example using the SGPLOT procedure.  You can place the columns on left or right.  In general, you can align columns of data with the discrete axis.  If you want a "bar" like entity, use VbarParm or HighLow plot (9.3) or Needle Plot (9.2).

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 306 views
  • 0 likes
  • 4 in conversation