doesnt show decimals

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

doesnt show decimals

[ Edited ]

I am using SAS 9.4. 

 

One column has number and words together (20.94 grams), and I needed to use the number only, so I used COMPRESS to get the numbers.

But, the number doesn't shows "." which made the number 2094 instead of 20.94. 

How can i fix this? 

 

Thank you.


Accepted Solutions
Solution
‎01-18-2018 02:00 PM
PROC Star
Posts: 7,971

Re: doesnt show decimals

Posted in reply to oenomel1992

One way would be to add the decimal point to your use of the compress function. e.g.:

data have;
  informat weight $15.;
  input weight &;
  want_weight=compress(weight,'.','kd');
  cards;
20.94 grams
;

Art, CEO, AnalystFinder.com

 

View solution in original post


All Replies
Solution
‎01-18-2018 02:00 PM
PROC Star
Posts: 7,971

Re: doesnt show decimals

Posted in reply to oenomel1992

One way would be to add the decimal point to your use of the compress function. e.g.:

data have;
  informat weight $15.;
  input weight &;
  want_weight=compress(weight,'.','kd');
  cards;
20.94 grams
;

Art, CEO, AnalystFinder.com

 

PROC Star
Posts: 1,066

Re: doesnt show decimals

Good morning @art297, Just a quick question if you may have a minute? 

Does kd stand for keep digits only?

PROC Star
Posts: 7,971

Re: doesnt show decimals

Posted in reply to novinosrin

@novinosrin: The documentation for the compress function can be found at: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212246.htm

 

The 'k' option is to "keep characters in the list." The 'd' option is to add digits to the list. Thus my suggestion was to add a period to the list, along with the d option (to include digits), and the k option to keep all of those characters (i.e., .0123456789)

 

Art, CEO, AnalystFinder.com

 

New Contributor
Posts: 3

Re: doesnt show decimals

Thank you, I just needed to add '.' :-)
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 125 views
  • 3 likes
  • 3 in conversation