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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 687 views
  • 0 likes
  • 1 in conversation