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;
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.
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.
rakeshvvv wrote:
some of the data is truncated…
Seems a bit vague.
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.
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.
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.