SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

How to format negative numbers?

Reply
Contributor
Posts: 30

How to format negative numbers?

Hi,

 

I have a dataset like the following. I would like to format all those numeric values to no decimals. Like -8 -4 4 for the first line. But after I used the Proc Format, all the negative numbers are missing. Could you help me?

 

char1 char2 char3
-8.00000 -4 4.00
-8.00000 -4 14.00
6.00000 8 4.00
-1.00000 3 4.00
6.00000 3 14.00
6.00000 0 4.00
6.00000 0 4.00
11.00000 3 4.00

Super User
Super User
Posts: 7,392

Re: How to format negative numbers?

Super User
Posts: 5,069

Re: How to format negative numbers?

[ Edited ]

The variable names CHAR1, CHAR2, and CHAR3 sound suspiciously like character variables.  Are they character or are they numeric?  

 

If you have non-zero values after the decimal point such as -8.3000, what would you like the result to be?  How about the result for an original value of -8.99?

 

You said you tried PROC FORMAT.  What did you already try, that didn't work?

 

If the value is positive such as 8.0000, should it also lose the zeros?  

 

The solution might be as simple as this:

 

char1 = scan(char1, 1, '.') ;

 

The harder part is spelling out the problem.

Super User
Posts: 10,458

Re: How to format negative numbers?

Show your proc format code.

Ask a Question
Discussion stats
  • 3 replies
  • 125 views
  • 0 likes
  • 4 in conversation