sas >> Decimal Values and Places

Hello,
I have a question regarding limiting the number of decimal values. In a
SAS dataset I have 8 variables whose values need to be restricted to 4
places and 2 variables whose values need to be restricted to 2 places.

If x = 54.46698 in the current SAS dataset, I want x = 54.4669.

I have used put function
do over pd;
pd = put(pd,11.4);
end;

which gives me a value of 54.467.

How can I avoid this rounding off and get the exact value and restrict the
decimal places.

Any help will be great. Thank You.

sas >> Decimal Values and Places

Jyothi ,

Multiple postings isnt going to get your question answered any faster, maybe
slower but definitly not faster.

I just notice something that disturbes me:

do over pd;
pd = put(pd,11.4);
end;

Looks like your trying to do an old style do loop with an array.

pd = put(pd,11.4);

Is Pd on the left hand side of the equal sign suppose to be the array
refernce, is the PD in the put function suppose to be a variable or an array
reference. When you make an array reference you need to do it like
PD(<index variable or value here>).

Also lets say the PD on the left and right hand side of the equals sign are
referncing a variable. Well SAS isnt going to like that. You are
attempting to change the type of a variable in mid stream, SAS doesnt like
this. The variable type is set at compile time and cannot be changed at
execution time.

So lets say you have a variable PD which is a numeric and you want to assign
its value up to the four decimal place to PD2 and you want PD2 to be a
character variable.

PD2 = Substr( put( PD , 11.5 ) , 1 , 10 ) ;

Now lets assume that you want PD2 to be a numeric:

PD2 = input( Substr( put( PD , 11.5 ) , 1 , 10 ) , 10.4 ) ;

I would guess that you could use some mathematical formula to transform the
numeric value originally in PD to the form you want, but when you do that
you darn well better have plenty of in code documentation explaining why
your doing this and how th e math works if it is complicated. No one like
to read code with magical numbers strewn through out and you cant count on
the person who is reading, using, or maintaining your code to be a math
wiz..

Toby Dunn

From: Jyothi Nekkalapudi < XXXX@XXXXX.COM >
Reply-To: Jyothi Nekkalapudi < XXXX@XXXXX.COM >
To: XXXX@XXXXX.COM
Subject: Decimal Values and Places
Date: Fri, 26 May 2006 10:17:09 -0400

Hello,
I have a question regarding limiting the number of decimal values. In a
SAS dataset I have 8 variables whose values need to be restricted to 4
places and 2 variables whose values need to be restricted to 2 places.

If x = 54.46698 in the current SAS dataset, I want x = 54.4669.

I have used put function
do over pd;
pd = put(pd,11.4);
end;

which gives me a value of 54.467.

How can I avoid this rounding off and get the exact value and restrict the
decimal places.

Any help will be great. Thank You.

Hello,
I have a question regarding limiting the number of decimal values. In a
SAS dataset I have 8 variables whose values need to be restricted to 4
places and 2 variables whose values need to be restricted to 2 places.

If  x = 54.46698 in the current SAS dataset, I want x = 54.4669.

I have used put function
do over pd;
pd = put(pd,11.4);
end;

which gives me a value of 54.467.
How can I avoid this rounding off and get the precise value, and limit the
decimal places.
Any help will be great.Thank You.

Out of the list of these statistics that come out of proc univariate,
which should typically have the extra decimal place that STD and
STDMEAN have? Is it only those variables starting with STD? Stated
another way, if I were to group variables into the MEAN camp and the
STD camp so that one set used the same format applied to MEAN and one
set used the format applied to STD then what variables should fall

CSS CV KURTOSIS MAX MEAN MIN MODE N NMISS NOBS RANGE SKEWNESS STD
STDMEAN SUM SUMWGT USS VAR P1 P5 P10 Q1 MEDIAN Q3 P90 P95 P99 QRANGE
NORMALTEST SIGNRANK PROBM PROBN PROBS PROBT T

My dataset has three numerical variables, when printed, they are 5
decimal places after the period. I added an variable AVG, through the
mean function:

DATA mydata;
...
AVG=MEAN( OF VAR1 VAR2 VAR3);
PROC PRINT DATA=mydata;
RUN;

The new variable only has 4 decimal places, how do I control this
behavior? i.e., I want all numbers with 5 decimal place.

Thanks,

Jindan

Hi,

Im going to write out SAS data in to txt format (delimiter is space)
and while doing that I would like to keep the decimal points for
different numeric variables as 2 only. Presently I have variables from
Var32 to Var56 and they have different widths (scales are different)
and different number of decimal places. I want to tamper around with
the number of decimal places only. Please suggest a way to do the same.

(Once am in front of SAS, I will try to see whether pasting from Log of
Proc export and changing the number of decimal places would do the
trick).

Regards,
Hari
India