02-05-2014 04:04 PM
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.
02-05-2014 04:32 PM
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).
02-05-2014 04:36 PM
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?
02-05-2014 04:48 PM
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.
Need further help from the community? Please ask a new question.