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

I have CSV file. I am importing into SAS dataset using proc import but as result some of the data is truncated…can someone suggest if there is any better way importing……

PROC IMPORT OUT=mydata

   DATAFILE="/c/clean.csv"

       DBMS=CSV REPLACE;

     delimiter = ";"; 

   GETNAMES=YES;

    DATAROW=2;

RUN;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

add guessingrows=32000 option if you must use proc import. There is a default number of rows SAS will use to determine type and length of variables. If you have longer text after that number of rows then it is likely to get truncated. The guessingrows option tells SAS to look at more lines before setting type and length.

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yes, use datastep (there are lots of examples on the communities):

data want;

     length var1-var4 $10;

     infile "c:\clean/.csv" dsd missover dlm="," lrecl=32767; /* Change DLM to semicolon if needed */

     input var1 $ var2 $ var3 $ var4 $;

run;

Obviously change the varx and format to what it is in your data, i.e. if you have dates and things, add formats, informats.

data_null__
Jade | Level 19

rakeshvvv wrote:

some of the data is truncated…

Seems a bit vague.

ballardw
Super User

add guessingrows=32000 option if you must use proc import. There is a default number of rows SAS will use to determine type and length of variables. If you have longer text after that number of rows then it is likely to get truncated. The guessingrows option tells SAS to look at more lines before setting type and length.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 824 views
  • 3 likes
  • 4 in conversation