To avoid wasting disk space and processing time, PROC IMPORT creates character variables with the minimum length. You could write the code yourself, but it’s a hassle when working with many different. CSV file: see this code by checking the SAS log. The PROC IMPORT is a convenience procedure to dynamically creates SAS code to read the. It bugs me SAS set the default (20) so low, and also there is no warning when truncation happens (even though SAS is good about printing notes, warnings, and errors for all sorts of other cases). Guessingrows=5 /* if omitted, the default is 20 */Įxamine the imported data set and notice all the numeric variables are fine but some of the character variables are truncated: Put read the csv file but only use 5 rows for guessing the width */ This Base SAS code demonstrates the issue: (Of course you’ll also see how to simply import a. I’ll also show how to programmatically modify the SAS registry using SAS code.
I will explain what happens, why, and two ways to fix it.
CSV has character strings with varying lengths (such as names, street addresses, and email addresses), then read carefully. CSV files always have character strings only with consistent widths (such as ISBN book codes, ethernet MAC addresses, UPC barcodes, Social Security Numbers) or numeric values only, then you may stop reading now. CSV files into SAS using the PROC IMPORT procedure. Watch out for this common pitfall when importing.