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

Greetings all.  I've got some string data that are numbers left padded with zeros.  In the source DB2 table they are decimal(10,0), but I am getting them from an Oracle database that includes text in the same column, and all the numeric data are zero padded to 10 characters long.  I though I could simply use input, but that is lopping off the right 2 characters.  This is what I am trying...

data _null_ ;

    string = '0123456789' ;

    num = input(string,8.) ;

    put num ;

run ; quit ;

I would expect the value of num to be 123456789, but it is ending up being 1234567.  I'm not sure why this is not working.  Any ideas?  Thank you.

Greg

1 ACCEPTED SOLUTION

Accepted Solutions
gsnidow
Obsidian | Level 7

DOH!  I was thinking that 8. would allow for the greatest number possible, but 10. works.

View solution in original post

4 REPLIES 4
gsnidow
Obsidian | Level 7

DOH!  I was thinking that 8. would allow for the greatest number possible, but 10. works.

ballardw
Super User

Don't forget to count the decimal point when reading decimal values as well.

Reading 1234.567  with 7.3 will also disappoint. (Hint: 1234.56 is 7 characters).

gsnidow
Obsidian | Level 7

So if I'm getting this right, for a 10 digit number, I need to use a numeric variable with length 6., but in the input statement I need to use 10 to specify the number of characters?

data_null__
Jade | Level 19

I would not bother to make ANY numeric variable length LT 8.  The W for an INFORMAT should be GE the longest string of digit characters, signs, decimals, commas and dollar signs being read.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 1657 views
  • 6 likes
  • 3 in conversation