I am trying to import a data set with multiple variables. I have no problem importing everything up until my date field. The data file is a .csv with an account number and a date per row of data followed by 24 columns (hours) of data. I am getting invalid data errors starting with date all the way through the 24 hours. I used yvar1-yvar24 for the hours in the day and date for my date field. My code looks like this:
length rate$4. account $11. meter $11. channel $13. lrid $16. name $33. units $5. legacy $11.;
informat date mmddyy10.; array yvar yvar1-yvar24;
infile 'K:\LOAD RESEARCH\CLP Rate Case Test Year 07-01-08 to 06-30-09\CSV Files Dist Run\w Legacy\input\1.csv' lrecl=350 missover dlm=',';
input account meter legacy channel lrid name units date mmddyy10. yvar1-yvar24;
The date in the csv file looks like this 07/18/2008. What am I doing wrong here?
Not off the top of my head. I could only force an error message by keeping your original code (i.e., before removing the extra informat specification) and having a date value less than 10 bytes long.
I wonder if there might be some other kind of problem that it just showing up as a date problem. I often use the DSD option on the INFILE statement (assuming that the CSV file fully conforms to standards, i.e., if a character field has an embedded comma, it is enclosed in double quotes).
By any chance are you looking at the CSV file in Excel and not a text editor? I have had occasions where saving a CSV from Excel results in dates converting from something 10/01/2008 to an Excel date offset integer value that usually would not be acceptable to the SAS informat.