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

 

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
1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

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

5 REPLIES 5
Ksharp
Super User
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;

ballardw
Super User

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.

 

Jagadishkatam
Amethyst | Level 16
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
ballardw
Super User

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

 

 

Jagadishkatam
Amethyst | Level 16

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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