I want ParkName to have 30 characters in the proc import statement while Guessingrows sets it to 24. The log says that the format statement is not supported.
proc import datafile="s:\workshop\data\np_traffic.csv"
dbms = csv
out = pg1.traffic replace;
guessingrows=max;
format ParkName $30.;
run;
Thanks!
@IrynaDemko wrote:
I want ParkName to have 30 characters in the proc import statement while Guessingrows sets it to 24. The log says that the format statement is not supported.
proc import datafile="s:\workshop\data\np_traffic.csv"
dbms = csv
out = pg1.traffic replace;
guessingrows=max;
format ParkName $30.;
run;
Thanks!
The length of 24 is the longest value encountered in this data set for the variable.
Changing the forrmat only effects display. If there are only 24 characters that's all there are. You would have to change the
INFORMAT to get 30 as the length and you can't do that with Proc Import.
When you use Proc Import you are in effect telling SAS to follow some arbitrary generic rules for determining variable properties and those rules will get things other than desired sometimes (or often in the case of some file formats) and based on the actual values encountered. If you want to have consistent results for multiple sets then do not rely on Proc Import.
Copy the code generated by proc import from the log to the program editor
and make there all required adaptations as adding length, format and other
statements.
It's possible you may need to add this before your PROC IMPORT code for the generated DATA step statements @Shmuel is referring to so that it shows in your SAS log:
options source;
@IrynaDemko wrote:
I want ParkName to have 30 characters in the proc import statement while Guessingrows sets it to 24. The log says that the format statement is not supported.
proc import datafile="s:\workshop\data\np_traffic.csv"
dbms = csv
out = pg1.traffic replace;
guessingrows=max;
format ParkName $30.;
run;
Thanks!
The length of 24 is the longest value encountered in this data set for the variable.
Changing the forrmat only effects display. If there are only 24 characters that's all there are. You would have to change the
INFORMAT to get 30 as the length and you can't do that with Proc Import.
When you use Proc Import you are in effect telling SAS to follow some arbitrary generic rules for determining variable properties and those rules will get things other than desired sometimes (or often in the case of some file formats) and based on the actual values encountered. If you want to have consistent results for multiple sets then do not rely on Proc Import.
Note that changing the informat used to convert text into values would not change the length of the variable either.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.