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.

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!

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.

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