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!
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)
For example:
PROC IMPORT DATAFILE=REFFILE
DBMS=CSV
OUT=WORK.IMPORT
guessingrows=32767;
RUN;
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.
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 how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.