DATA Step, Macro, Functions and more

Indentation does not appear in the format when opened in the output window

Accepted Solution Solved
Reply
Trusted Advisor
Posts: 1,137
Accepted Solution

Indentation does not appear in the format when opened in the output window

[ Edited ]

 

Dear Experts,

 

I would like to see the indentation appear in the proc format library from the output window. For example I created the format $gen as below where the female value has leading space (indent) and the male value is without the leading space or indent. However when i apply this format to derive a new variable, the variable gets the indentation applied. But when i see the format from proc format library from output window i dont see the indentation(leading space), however indentation appears in the dataset for new variable.

 

I am working on sas 9.4.

 


proc format;
value $gen
'F'=' Female'
'M'='Male'
;
run;


data class;
set sashelp.class;
gender=put(sex,$gen.);
run;

 

Capture1.PNG

 

Capture2.png

Thanks,
Jag

Accepted Solutions
Solution
‎04-27-2017 09:19 PM
Trusted Advisor
Posts: 1,137

Re: Indentation does not appear in the format when opened in the output window

Thank you @ballardw, the use of null characters (Alt+255 on the numeric keyboard) while creating the format label worked. Now I am able to get the space displayed for the format in the output window.

 

Capture3.PNG

Thanks,
Jag

View solution in original post


All Replies
Super User
Posts: 10,028

Re: Indentation does not appear in the format when opened in the output window

Posted in reply to Jagadishkatam
SAS will strip the blank , when the string is printed in output.
Check the real value by proc format.


proc format;
value $gen
'F'=' Female'
'M'='Male'
;
run;
proc format cntlout=xx;
 select $gen ;
run;

Super User
Posts: 11,343

Re: Indentation does not appear in the format when opened in the output window

Posted in reply to Jagadishkatam

By "output window" do you mean the traditional text only based output window or do you mean the ods results? Different output destinations behave differently and sometimes for the same procedures.

 

The style attibute ASIS will preserve leading space in output for those procedures that allow the option but I believe those are mostly the report procedures Proc Print, Report and Tabulate for actual DATA display. I suspect that Proc Format cannot use that option.

 

Trusted Advisor
Posts: 1,137

Re: Indentation does not appear in the format when opened in the output window

Thanks @ballardw @Ksharp for your responses.

The output window here I mean it is the default output window to which the output is directed and is not the ods destination, as i did not mention the ods statement. But i have seen some formats which have displayed the indented label in the output window. So wanted to check how is it possible to get the format label with indentation in the output window as well.
Thanks,
Jag
Super User
Posts: 11,343

Re: Indentation does not appear in the format when opened in the output window

Posted in reply to Jagadishkatam

Proc Tabulate has the option INDENT=<a number of spaces> for nested row headings.

 

You may be able to use null characters (Alt+255 on the numeric keyboard) in the format code. The procedures generally do not consider that character as a "blank" to be removed and forces a display with leading "space".

Of course any ouput going to any destinations with proportional fonts and that format may not align as expected

 

 

Solution
‎04-27-2017 09:19 PM
Trusted Advisor
Posts: 1,137

Re: Indentation does not appear in the format when opened in the output window

Thank you @ballardw, the use of null characters (Alt+255 on the numeric keyboard) while creating the format label worked. Now I am able to get the space displayed for the format in the output window.

 

Capture3.PNG

Thanks,
Jag
☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 143 views
  • 0 likes
  • 3 in conversation