BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi ,
I have used the following proc fromat for displaying some percentage values with + or - in decimals.(Eg: +7.7 , -0.8 etc).But this proc format works only for values greater than or less than 0. But i need to display the format for the value 0 also.( like +0.0 or -0.0).
PROC FORMAT;
PICTURE plusmin low -< 0 = '0,009.9' (prefix = '- ' )
0 <- high = '0,009.9' ( prefix = '+ ' )
;
Please help me ASAP.
Thanks,
Sandhya
3 REPLIES 3
deleted_user
Not applicable
> Hi ,
> I have used the following proc fromat for displaying
> some percentage values with + or - in decimals.(Eg:
> +7.7 , -0.8 etc).But this proc format works only for
> values greater than or less than 0. But i need to
> display the format for the value 0 also.( like +0.0
> or -0.0).
> PROC FORMAT;
> PICTURE plusmin
> low -< 0 = 0009.9 (prefix = '-' )
> 0 <- high = '0,009.9' ( prefix = '+ ' )
> Please help me ASAP.
> Thanks,
> Sandhya
deleted_user
Not applicable
You were nearly there! Try this code:

PROC FORMAT;
PICTURE PLUSMIN
LOW-<0="0,009.9" (PREFIX="-")
0-HIGH="0,009.9" (PREFIX="+");
RUN;

Note that you will need to associate the format with a variable using a width e.g. FORMAT NUMBER PLUSMIN8.;
to give extra room at the front for four-digit values, otherwise you lose the '+' sign.

Robert
deleted_user
Not applicable
Sorry, due to technical problems, my earlier reply was truncated. Here follows the full text.

You were nearly there! Try this code:

PROC FORMAT;
PICTURE PLUSMIN
LOW -< 0="0,009.9" (PREFIX="-")
0-HIGH="0,009.9" (PREFIX="+");
RUN;

Note that you will need to associate the format with a variable using a width e.g.
FORMAT NUMBER PLUSMIN8.;
to give extra room at the front for four-digit values, otherwise you lose the '+' or '-' sign.

Robert

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
  • 3 replies
  • 669 views
  • 0 likes
  • 1 in conversation