Solved
New Contributor
Posts: 2

# Question with w.d format

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

Accepted Solutions
Solution
‎06-11-2013 01:53 PM
Super Contributor
Posts: 334

## Re: Question with w.d format

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

All Replies
Solution
‎06-11-2013 01:53 PM
Super Contributor
Posts: 334

## Re: Question with w.d format

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

New Contributor
Posts: 2

## Re: Question with w.d format

Thanks! the issue has been resolved.

Super User
Posts: 6,771

## Re: Question with w.d format

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.

🔒 This topic is solved and locked.