rounding and truncating??

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

rounding and truncating??

Samuel Solomon
dear all,
how can i round decimals in to 2 or 3 or 4 ....or rth decimal places.
thanks
samuel.

====================To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: rounding and truncating??

Art Kendall-2
if you just want to change how the number is displayed try something like
formats myvar (f4).
if you want to show no places or
formats myvar(f6.3).
to show 3 places etc.

if you want to have a variable with an actual change to the contents try
something like
compute newvar0 = rnd(oldvar).
to round to an integer.
or
compute newvar2 = rnd(100*oldvar)/100.
to have 2 places after the decimal.

Art Kendall
Social Research Consultants

Samuel Solomon wrote:

> dear all,
> how can i round decimals in to 2 or 3 or 4 ....or rth decimal places.
> thanks
> samuel.
>
> ===================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>
>
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD