0
votes

I am trying to find out the format and informat to the below. I have a .csv file with contain values like 10,900,900.111111 or 999.999 I use the File Reader to read this .csv file. Default File Reader type of value is 'Character' length '8' I used INPUT to convert to Numeric and TRANWRD to replace 'comma' to 'space' and received 109009 value. Which format and informat should I use to with high accuracy reflect the comma and decimal data. Currently the largest number of displayed digits in Sas table have eight digits and in my .csv file some number have as many as sixteen digits. Thank you,

1
Please post example data, your code, and an example of what you're currently getting, and an example of what you'd like to get. - Stu Sztukowski
my data is 10,900,900.111111 in .csv. In File reader default data is in character so I use INPUT(&data.best) to convert on Numeric not sure if TRANWRD function is need to replace "comma" to "space". My output is 109009 but I need more accuracy result like 1090900.11.. .I am not sure if it possible to display value with comma like 10,900,900 - SASUSER

1 Answers

0
votes

First a note of caution: 16 digits is the maximum you can represent accurately in 8 byte numerics (the way SAS uses them, anyway), and even some 16 digit numbers are not representable (most of the ones beginning with 9, in IEEE floating point systems, like Linux/Unix or Windows).

That aside; the correct informat to read 10,900,900.111111 is comma17., and you could use a longer one if larger numbers are possible - make sure the 17 is equal to the total text length of the number. Also make sure to use a longer format than default (best12. is default) to display it, as otherwise you'll lose some apparent precision (the number will be fully precise, but it will be displayed less precisely).

data _null_;
  x = input('10,900,900.111111',comma17.);
  put x= best32.;
run;

If you wanted to remove the commas, you could do that with compress which is sort of like tranwrd (or the more common translate) except it removes things; so you could do nocomma = compress(commastr,','); and it would remove the commas.