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

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. 

schatr2_0-1634830332093.pngschatr2_1-1634830418619.pngschatr2_2-1634830450462.png

schatr2_0-1634830660298.png

 

schatr2_3-1634830489332.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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';

 

View solution in original post

4 REPLIES 4
ballardw
Super User

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.

Reeza
Super User

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...

 

 

FreelanceReinh
Jade | Level 19

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';

 

393310
Obsidian | Level 7

This worked perfectly, thank you so much!!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1740 views
  • 0 likes
  • 4 in conversation