Help using Base SAS procedures

How to change the length of numeric variable

Reply
Contributor
Posts: 49

How to change the length of numeric variable

Hi,

I ran a proc means procedure to get mean and standard deviation for my data. However, the length for them are 12, eg, mean=0.0578154391, std=0.0245687672. I only want to have 3 decimal places and total length is 5, that is, mean=0.057, std=0.024, and they still have to be numeric. How should I do it? Thank you very much.

Lu
Regular Contributor
Posts: 165

Re: How to change the length of numeric variable

Try

proc means data = one maxdec=3;
var ...;
run;

Good luck!
Contributor
Posts: 49

Re: How to change the length of numeric variable

Sorry I didn't make myself clear. I also used the output statement in proc means prodecure and get a sas dataset: data1 to include the mean and std, I mean how to change the length of mean and std in data1.

Lu
Regular Contributor
Posts: 165

Re: How to change the length of numeric variable

Do you really want to round the values or do you just want to change the format for when they are displayed? You can use proc datasets to change the format of the output dataset.
Regular Contributor
Posts: 165

Re: How to change the length of numeric variable

It also looks like if you use the format statement in proc means the output dataset will inherit the formats for those variables.
Contributor
Posts: 49

Re: How to change the length of numeric variable

Thank you very much. Your reply reminded me the round function, by which I can change the decimal place for mean and std. Thanks!

Lu
Ask a Question
Discussion stats
  • 5 replies
  • 307 views
  • 0 likes
  • 2 in conversation