DATA Step, Macro, Functions and more

To get decimal observation only

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 116
Accepted Solution

To get decimal observation only

Hi,

Can someone would love to help me to recognize (extract) the observations in numeric variable only, which contain decimal part.

It would be great, if we can count the decimal digits as well.

1. I have around 300 datasets (tables) with around 1250 variables which need to be investigate to assign format and informat for numeric variable.

2. Some observations are also missing, it means it has ".".

if question is not clear, please let me know. I would try to explain more.

Regards

Uma Shanker Saini


Accepted Solutions
Solution
‎11-12-2014 08:32 AM
Super User
Posts: 6,963

Re: To get decimal observation only

use

if x ne int(x)

to find numbers with decimal parts.

To count the decimal digits:

num_digits=length(scan(put(x,best32.),2,'.'));

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Frequent Contributor
Posts: 116

Re: To get decimal observation only

Hi,

Please forget about multiple tables, Only one dataset and one variable.

Uma

Solution
‎11-12-2014 08:32 AM
Super User
Posts: 6,963

Re: To get decimal observation only

use

if x ne int(x)

to find numbers with decimal parts.

To count the decimal digits:

num_digits=length(scan(put(x,best32.),2,'.'));

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Frequent Contributor
Posts: 116

Re: To get decimal observation only

Hi Kurt,

Thanks for your quick response.

Let me verify this one with dummy data...

Frequent Contributor
Posts: 116

Re: To get decimal observation only

Hey buddy,

Thanks, it would help a lot, just i need to add some extra fancy things into it.

take care

www.sascertguru.com

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 2576 views
  • 0 likes
  • 2 in conversation