12-21-2015 08:48 PM
Hello, I have another problem when importing my CSV file into SAS
There is a variable "State", and most of the values are like PA, NJ, NY, etc, but there a few cases they are using "New York", "New Jersey" etc. I can see these im excel. But when I imported into SAS, they were truncated as "Ne".
I can edit the CSV file before importing. But I wonder if there is a way to handle this more efficiently so I do not need to eidt the CSV in Excel manually? The fils is pretty charge (more than 1 million cases), so I hope I can find a better way.
Thank you in advance!
12-21-2015 09:12 PM - edited 12-21-2015 09:17 PM
One option: you can increase the scaned rows from the input file to determine the appropriate data type and length of columns. By adding the option guessingrows = 32767 (maximum for Base SAS 9.2 ) or more till 2147483647 (maximum for Base SAS 9.3 and later)
PROC IMPORT DATAFILE=REFFILE DBMS=CSV OUT=WORK.IMPORT guessingrows=32767; RUN;
12-21-2015 09:21 PM
12-21-2015 09:31 PM - edited 12-21-2015 09:32 PM
You should be consider that this option come with performance penalty for the scanning, even if it is easier. The best way is to run PROC IMPORT on your data set then copy the generated DATA step from the log and increase your column length which is truncated, then run this DATA step after your modifications. This could be the best solution as it is work environment and your dataset tend to be big one.
12-21-2015 09:15 PM