The SAS Output Delivery System and reporting techniques

enforce format DEFINE mypercent / '%' format=f12.1;

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 133
Accepted Solution

enforce format DEFINE mypercent / '%' format=f12.1;

[ Edited ]

Hello SAS Experts,

I have applied  format=f12.1; to my proc report column but if there are no decimal places then no formatting happens.

How can I enforce that even if there is no decimal place I can read 100,0 or 90,0 and not just 100 and 90?

 

@RW9,  I know it might be a strange thing to do to make up information on decimals which isnt there but this is an aesthetic requirement by the end user, I cant help it Smiley Happy


Accepted Solutions
Solution
‎10-14-2015 03:47 AM
SAS Super FREQ
Posts: 8,815

Re: enforce format DEFINE mypercent / '%' format=f12.1;

Hi:

  This is almost acting like the BEST format is being used instead of the format you specified. If you run the attached code, you can see the difference between using a format and using the BEST format (which is what most SAS procedures default to).

 

  You did not post any data or your full code or your destination of interest. Another possibility is that you are opening the output in Excel and Excel is losing the format.

 

  This code correctly shows the 1 decimal place for the values for HEIGHT and WEIGHT and the use of the BEST format shows the decimal place not being used.

 

  So without knowing more about your code and your destination, perhaps this will point you in the right direction.

 

cynthia

 

proc report data=sashelp.class nowd;
column name age sex height weight height=htbsfmt weight=wtbsfmt;
define name / order;
define height / f=12.1;
define weight / f=12.1;
define htbsfmt / f=best12.1;
define wtbsfmt /f=best12.1;
run;

View solution in original post


All Replies
Solution
‎10-14-2015 03:47 AM
SAS Super FREQ
Posts: 8,815

Re: enforce format DEFINE mypercent / '%' format=f12.1;

Hi:

  This is almost acting like the BEST format is being used instead of the format you specified. If you run the attached code, you can see the difference between using a format and using the BEST format (which is what most SAS procedures default to).

 

  You did not post any data or your full code or your destination of interest. Another possibility is that you are opening the output in Excel and Excel is losing the format.

 

  This code correctly shows the 1 decimal place for the values for HEIGHT and WEIGHT and the use of the BEST format shows the decimal place not being used.

 

  So without knowing more about your code and your destination, perhaps this will point you in the right direction.

 

cynthia

 

proc report data=sashelp.class nowd;
column name age sex height weight height=htbsfmt weight=wtbsfmt;
define name / order;
define height / f=12.1;
define weight / f=12.1;
define htbsfmt / f=best12.1;
define wtbsfmt /f=best12.1;
run;

Frequent Contributor
Posts: 133

Re: enforce format DEFINE mypercent / '%' format=f12.1;

[ Edited ]

Hi Cynthia,
Thanks for your reply! Indeed, it is MS Excel cutting off the 0 :/

The format=nlnum32.2; format worked, MS Excel did not cut off the zero's.

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 527 views
  • 1 like
  • 2 in conversation