BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dyang
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
esjackso
Quartz | Level 8

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

View solution in original post

3 REPLIES 3
esjackso
Quartz | Level 8

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

dyang
Calcite | Level 5

Thanks! the issue has been resolved. Smiley Happy

Astounding
PROC Star

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.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1006 views
  • 6 likes
  • 3 in conversation