Hello,
I am trying to format my output variables after running proc logistic. SAS is automatically giving me "scorad_scratch mild vs none" and I want it to just say "mild vs none". I have tried to use proc format, however, it is not following my custom format. Any help would be appreciated. I am using SAS studio. I have also tried if then statement as well which did not work.
Hello @393310 and welcome to the SAS Support Communities!
@393310 wrote:
SAS is automatically giving me "scorad_scratch mild vs none" and I want it to just say "mild vs none". I have tried to use proc format, however, it is not following my custom format. (...) I have also tried if then statement as well which did not work.
The reason in both cases is that the strings contained in variable Effect are:
scorad_scratch mild vs none scorad_scratch moderate vs none scorad_scratch severe vs none
The string in question contains five blanks between "mild" and "vs none", but HTML output compresses multiple blanks to one. [That's one of many reasons why I prefer Listing output.]
So you need to insert the four missing blanks in your VALUE statement. Moreover, your format $effects has default length 12 (= length of the label "mild vs none"), which leads to truncation of the other values (although they are unformatted otherwise). To avoid this, you should either add an explicit length specification in the FORMAT statement (of the PROC PRINT step) -- $effects31. -- or define a sufficient default length in the VALUE statement:
value $effects (default=31) 'scorad_scratch mild vs none' = 'mild vs none';
Easiest is likely to send the output of the tables to a data set. Then you can use a data step or other report tools to modify appearance. Look up ODS OUTPUT to send output table(s) to data sets.
Otherwise you have to find the SAS template that controls the appearance of that table and modify the template.
Here's some instructions and explanations on how to capture output that is shown via ODS.
https://blogs.sas.com/content/sastraining/2017/03/31/capturing-output-from-any-procedure-with-an-ods...
Hello @393310 and welcome to the SAS Support Communities!
@393310 wrote:
SAS is automatically giving me "scorad_scratch mild vs none" and I want it to just say "mild vs none". I have tried to use proc format, however, it is not following my custom format. (...) I have also tried if then statement as well which did not work.
The reason in both cases is that the strings contained in variable Effect are:
scorad_scratch mild vs none scorad_scratch moderate vs none scorad_scratch severe vs none
The string in question contains five blanks between "mild" and "vs none", but HTML output compresses multiple blanks to one. [That's one of many reasons why I prefer Listing output.]
So you need to insert the four missing blanks in your VALUE statement. Moreover, your format $effects has default length 12 (= length of the label "mild vs none"), which leads to truncation of the other values (although they are unformatted otherwise). To avoid this, you should either add an explicit length specification in the FORMAT statement (of the PROC PRINT step) -- $effects31. -- or define a sufficient default length in the VALUE statement:
value $effects (default=31) 'scorad_scratch mild vs none' = 'mild vs none';
This worked perfectly, thank you so much!!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.