07-06-2015 07:26 AM
I'm reading in a file with loads of fields from a txt file. I'm having a couple of problems with the formatting
One of the fields is a date field with length 10 in the format 01/01/2010 but it also contains blanks where the date missing.
Here is my code
DATA PC ;
INFILE PC DLM =',' DSD MISSOVER DSD LRECL = 2000 ;
To allow for the blanks, do I need to read it in as a character and then create a new variable with the correct format using sas code.
Also, is there a way to convert to sasdate in the input statement?
One of the other fields, Comm is length 17 in the txt file (including the decimal point) and had two decimal places. Is the above format correct? ie is the 17 in 17.2 the total length of the field including decimal points and .2 the number of decimal places?
07-06-2015 09:56 AM
Do not use formats in the input statements, because formatted input ignores the delimiter,
Specify the informats with an INFORMAT statement and then use list input without formats.
07-06-2015 10:05 AM
In addition to KurtBremser's suggestion, also note that the 17.2 informat might be incorrect. You might be better off with an informat of 17.
The difference occurs when the incoming data does not contain a decimal point. If the incoming data contains "12345", for example:
"12345" with 17. informat ==> 12345
"12345" with 17.2 informat ==> 123.45
As an informat, 17.2 looks for decimal points and inserts them when the incoming string does not contain a decimal point.
Finally, note that you may not be able to store exactly a numeric that contains 16 significant digits. You might lose a little precision from the end of the value.