## To get decimal observation only

Solved
Frequent Contributor
Posts: 120

# 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: 10,280

## 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
How to convert datasets to data steps
How to post code

All Replies
Frequent Contributor
Posts: 120

## Re: To get decimal observation only

Hi,

Uma

Solution
‎11-12-2014 08:32 AM
Super User
Posts: 10,280

## 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
How to convert datasets to data steps
How to post code
Frequent Contributor
Posts: 120

## Re: To get decimal observation only

Hi Kurt,

Let me verify this one with dummy data...

Frequent Contributor
Posts: 120

## 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 and locked.