BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
HitmonTran
Pyrite | Level 9

Hello,

 

When  I proc import my CSV file, some of the values are truncated.  I'm think because the first variable has a length=39, which is causing longer variables to be truncated.  How do i avoid this issue?

%web_drop_table(WORK.IMPORT1);


FILENAME REFFILE "data.csv";

PROC IMPORT DATAFILE=REFFILE
	DBMS=csv
	OUT=WORK.IMPORT1;
	GETNAMES=YES;
RUN;

PROC CONTENTS DATA=WORK.IMPORT1; RUN;


%web_open_table(WORK.IMPORT1);

 

excel spreadsheet variable:

HitmonTran_0-1708189160943.png

 

data truncated:

HitmonTran_1-1708189224605.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

PROC IMPORT is a guessing procedure, it sometimes guesses wrong. But for CSV files, the code used by PROC IMPORT is in the log, you could easily copy the code out of the log and then modify it so that it works on your data. Or, you can add the option GUESSINGROWS=MAX; into your PROC IMPORT code and this ought to work as well, but it will take a very long time if you have a large data set.

 

And what do the calls to the two different macros have to do with anything?

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

PROC IMPORT is a guessing procedure, it sometimes guesses wrong. But for CSV files, the code used by PROC IMPORT is in the log, you could easily copy the code out of the log and then modify it so that it works on your data. Or, you can add the option GUESSINGROWS=MAX; into your PROC IMPORT code and this ought to work as well, but it will take a very long time if you have a large data set.

 

And what do the calls to the two different macros have to do with anything?

--
Paige Miller
ballardw
Super User

CAUTION: You show your  CSV file opened in Excel. You want to be very careful with this as if you accidentally SAVE the file when closing Excel (such as you widened a column for readability which Excel interprets as a change to the file) as Excel will change some values when saving the file. Which means that your CSV may misbehave in a number of ways.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2107 views
  • 0 likes
  • 3 in conversation