Reputation: 610
I am converting numeric variables (p-values) to character variables by way of the put function. I would like to retain the pvaluew.d format's usage of '<.0001' for values of less than .0001. I am using the code below:
newvar=put(round(oldvar,.0001),pvalue6.4);
I ran into an issue with this. The newvar ended up being either 1 or <.0001 when I used this. I wasnt able to reproduce this error when I tried it on other parts of my code, leading me to believe that something else I did was the problem.
Using an example, I used the above transformation and the one below on a variable with some random p-values in it:
newvar2=put(oldvar,pvalue6.4);
The results are identical. Should this always be the case, that the two strings of code will produce identical resutls, and my previous error was due to another cause, or could there be instances of differing results? I could just use a 6.4
format for the put function and change any 0.0000 to <.0001 manually, but prefer to let SAS do it for me.
Upvotes: 0
Views: 3765
Reputation: 63424
Most formats automatically round when displaying, so you shouldn't need to do the rounding.
data _null_;
do x=.00004,.00006,.00014,.00016;
y=round(x,.0001);
put x= pvalue6.4 y= pvalue6.4;
end;
run;
The only difference between the two processes is that the pvalue
format will display numbers from .0005 - .000999 as '<.0001' while rounding first will display those numbers as equal to .0001. Which is correct for your project is your choice; I suspect most would prefer the former, unless you felt that .0001 was the furthest significant digit you can correctly display.
Upvotes: 1