Hello,
I am trying to read in the '000010000' string to a numeric value of 1.0 (5 digit number and 4 decimals) but the syntax below would return the value of 0.1 instead.
Value=Input('000010000', 5.4);
Put Value=;
Log:
Value=0.1;
Does someone know how to convert the value properly?
Any help would be greatly appreciated.
Thanks,
Daniel
I believe the width needs to be the length of the string otherwise you lose the needed zeros.
Try:
data t;
Value=Input('000012000', 9.4);
Put Value=;
run;
Should get 1.2
Hope this helps!
EJ
I believe the width needs to be the length of the string otherwise you lose the needed zeros.
Try:
data t;
Value=Input('000012000', 9.4);
Put Value=;
run;
Should get 1.2
Hope this helps!
EJ
Thanks! the issue has been resolved.
Using the same reasoning, the results of your original test should have been 0.0001, not 0.1.
The "4" in "9.4" (or in "5.4") is actually tricky. It means, "Inspect the incoming string to see if it contains a decimal point. If it does, use it. But if there is no existing decimal point, assume that the last 4 digits read should fall after the decimal point."
Good luck.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.