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

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 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

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;

metallon
Pyrite | Level 9

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.

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
  • 2 replies
  • 2217 views
  • 1 like
  • 2 in conversation