Hi,
can you please tell me how to convert scientific character to numeric value in SAS VA.
quantity = "1.66666666666666E-06"
I tried to Parse text to numeric value.But, somehow I got wrong result.
Thanks.
Is it possible that some of your values have a greater degree of precision than the example value you provided?
The more decimals there are in front of the E, the wider your format (really an informat) width needs to be on the Parse operator.
Hello,
You are on the right track with the Parse operator, but the parameters are a little tricky.
What you will want to do is create a calculated item using the Parse operator, specifying the F format and a width that is wide enough to handle your values. For example, you need to specify at least width 20 to handle the value 1.66666666666666E-06.
You will also need to ensure that your output format (at the bottom of the New Calculated Item window) displays the values like you want. If you specify Numeric with width 20, the value is displayed as 1.66666666666666E-06 but it is processed appropriately as a numeric. If you specify Numeric with width 24, the value is displayed as 0.00000166666666666666 because the width is wide enough to display all the zeroes.
Does that help?
Thanks,
Sam
Hi Sam,
thank you for the reply. I am using 7.1 and I have a value zero instead of 0.00000166666666666666. As mentioned, I first parsed with F with width 20 and then applied Numeric width 24 in Measure. How ever, I have got the value zero.
Thanks.
Kind regards,
Ajaykumar
Is it possible that some of your values have a greater degree of precision than the example value you provided?
The more decimals there are in front of the E, the wider your format (really an informat) width needs to be on the Parse operator.
Hi Sam,
indeed. The length was 21 instead of 20. And it worked like a magic when I gave the informat length to be 21.
Thank you very much.
Kind regards,
Ajay
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.