BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
IrynaDemko
Calcite | Level 5

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!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@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.

View solution in original post

4 REPLIES 4
Shmuel
Garnet | Level 18

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.

SASKiwi
PROC Star

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;
ballardw
Super User

@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.

Tom
Super User Tom
Super User

Note that changing the informat used to convert text into values would not change the length of the variable either.

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 2208 views
  • 2 likes
  • 5 in conversation