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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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