Help using Base SAS procedures

Numeric - Double precision in SPDS

Reply
N/A
Posts: 0

Numeric - Double precision in SPDS

Hi all,

We have set of numeric variables in a dataset. It's having double precision value in it. We could not identify format or informat while describing the table.

How we would be able to identify the minimum and maximum precision values?

Thanks in advance.

Regards,
Satya
Super Contributor
Super Contributor
Posts: 3,174

Re: Numeric - Double precision in SPDS

Read this documentation reference about SAS numeric variables and precision (internal), and you would need to use the appropriate output FORMAT for displaying your data.

Scott Barry
SBBWorks, Inc.

SAS Variables

Numeric Precision in SAS Software
http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000695157.htm
N/A
Posts: 0

Re: Numeric - Double precision in SPDS

Thanks for the quick reply.

Sorry, my earlier post was not clear.

The columns are calculated columns and has internal precision value as '.', though it contains precision values.

So I am not able to Identify the maximum precison value this numeric field holds.

Please suggest.

Regards,
Satya
Super Contributor
Super Contributor
Posts: 3,174

Re: Numeric - Double precision in SPDS

You are indicating that the variable value is a SAS MISSING (or sometimes considered a NULL) value. There is the same precision for such a variable, determined by the SAS LENGTH associated with the variable. If unspecified, the default is SAS numeric length 8 (unless overridden).

Your condition appears to be that your SAS variable is not being computed, so you will want to review your SAS code.

Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: Numeric - Double precision in SPDS

To give an example if my data is,

Col1
-----
50
10
10

Col2
-----
3
2
4


And my derived column is :

Col3 = Col1 / Col2;

In this case the output is,

Col3
-----
16.66666
5
2.5

If I have to identify the maximum precision value, then in this case it is '5'. Now is there any function or utility which will help me identifying this maximum precision.

Regards,
Satya
Super Contributor
Super Contributor
Posts: 3,174

Re: Numeric - Double precision in SPDS

You do not need to identify any maximum precision. The only reason to shorten the SAS LENGTH of a numeric variable would be to conserve disk space -- normally something you need not be concerned about. What you need to be concerned about is what "output format" to use, given your data -- again a default assignment normally satisfies the condition.

Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: Numeric - Double precision in SPDS

Basically I want to migrate this dataset into another database eg.Oracle. So to create a table in Oracle, I should know maximum decimal precision value / attribute definition for that column to migrate this column to Oracle.
N/A
Posts: 0

Re: Numeric - Double precision in SPDS

I have tried the following code using data step and proc sql techniques. Let me know if it doesn't fit your requirement.

data sample;
input col1 col2;
cards;
50 3
10 2
10 4
;
run;

data sample1(drop=col3_c);
set sample;
col3=col1/col2;
col3_c=left(put(col3,best.));
precision=length(scan(col3_c,2, '.'));
run;

proc sql;
create table sample2 as
select col1, col2, col3, max(precision) as max_precision
from sample1;
quit;

~Sukanya E
Super Contributor
Super Contributor
Posts: 3,174

Re: Numeric - Double precision in SPDS

Consider using SAS PROC MEANS to analyze your SAS numeric data, if you need to know about data-value range.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 8 replies
  • 135 views
  • 0 likes
  • 2 in conversation