Hi All,
I am using Proc Import to import a .csv file into SAS. I need to force some columns to be treated as text during the import, I have two issues: there is an "account number" column which is *numeric* however many accounts having lead 0's that must remain (i.e. i can NOT have "00000245" imported as "245" as it is currently doing), also there is a "date" column which is a date in mm/dd/yyyy format, however it is missing for many of the rows -- this is expected in terms of my data to have some rows missing a date, but the rows should still be imported all the same, but because it autoformats that column to a date i get errors for "invalid data" on each row with a missing date, and soon the import fails because of too many invalid data errors.
Is there anyway I can force columns to import as pure text and ignore formatting with proc import? If not, is there another way that I can import this data into SAS in this fashion?
Thanks!!
-Ryan
Use the import then recall the generated datastep code, use F4 or go to the log and copy back into the editor. The variable informat and informat assignments will show in the code. Change them from probably best3.2 or similar to $20. or what ever length you need. Then add a $ after the variable in the INPUT statement corresponding those variables.
You can suppress the warning messages for the dates by using ?? after the variable name in the input statement.
If you are going to read the same data format multiple times generating datastep code this way is very beneficial as you can make adjustments to character variables that may change size such as city names or customer comments and allow additional room for later versions.
Also adding meaningful labels will likely be helpful in the long run.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.