BookmarkSubscribeRSS Feed
JinboZhao
Calcite | Level 5

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

3 REPLIES 3
Astounding
PROC Star

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.

ballardw
Super User

Show your proc format code.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 11043 views
  • 0 likes
  • 4 in conversation