Sunday, May 24, 2009

Truncate issue when importing CSV file

CSV file is an old common format of information distribution. However, when we read CSV into SAS dataset using PROC IMPORT, the string is truncated sometimes.
The reason is that PROC IMPORT scan only 20 records by default to determine variable attributes. SAS Notes has detailed the steps to solve the issue.

For more information, please see http://support.sas.com/kb/1/075.html.

*Sample code to read CSV;
PROC IMPORT OUT= WORK.DATA
DATAFILE= "csv.txt"
DBMS=DLM REPLACE;
DELIMITER='2C'x;
GETNAMES=YES;
DATAROW=2;
RUN;

No comments: