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!
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.
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)
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.
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.
Thank you!!! I definitely wasn't anticipating such a simple solution. 🙂
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).
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.