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.

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 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
  • 9626 views
  • 0 likes
  • 4 in conversation