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
DOH! I was thinking that 8. would allow for the greatest number possible, but 10. works.
DOH! I was thinking that 8. would allow for the greatest number possible, but 10. works.
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).
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?
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.
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.
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.