Greetings:
Trying to figure out an efficient way to read in a very simple CSV file by using Data step (part of my practice for input, infile, informat etc.)... I know how to do this using the import wizard but I simply could not find the way to use a data step for the date field.
CSV data: (comma delimited)
Abby 1/1/2000
Andy 2/1/2001
Here is the code I tried first, which did not give an error message but date values were showing up as missing.
Filename csvTest 'C:\Documents and Settings\Desktop\SAS_Learning\review\test.csv';
The second puzzle: I added a year value as the third variable. (e.g. Abby, 1/1/2000, 2000).
Then I ran the code with a slightly modified input statement (input first_name $ order_date mmddyy10. order_year 😉 . This time the SAS dataset has the right order_date but the year showed up as 0 for the example.
Any advice? Do you think I should only use Proc Import to read in CSV and give up the Data step?
Hi:
If you use the colon modifier for the INPUT statement, you will be instructing SAS to read the data using a specific INFORMAT (in this case MMDDYY10.). For more about the colon modifier for INPUT, read the documentation topic entitled: "Modified List Input" which shows examples of the colon format modifier: http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a003209907.htm