I have an Access database (accdb) with several long text variables. When I import it to SAS, they are truncated to 3 characters (including many and with a question mark, like xx?)
Please advise!
Thank you
It will help to show the code used.
This is what I use
Proc import out=test datatable="datatable" dbms=access replace;
database="path";
scanmemo=yes;
usedate=no;
scantime=yes;
run;
Thank you
What do you get when you run proc contents on the dataset Test?
When I run proc content, those variables show up as "Char, length 3, format $3, informat $3"
I would suspect the MEMOSIZE option was set to 3 but you didn't show that in the code.
If the source data set isn't too large I would try exporting if from Access to a CSV file and look at that. If that looks okay then import that into SAS and see if there are still issues. If so, then you may issues related to the actual content.
I tried to set memosize to a big number but it did not work
When I exported it from Access to Excel, things looked OK (but I lost a date/time variable which only the date part showed up) and I was able to import to SAS without that truncate problem.
But I hope we could do the import from Access without going through Excel
Any suggestions on this?
Thank you
I would suggest that you export your access data to CSV, then datastep to read it in - this gives the benefit of being able to see the data in plain text and having control over what happens at read in time. I would also recommend not using Access, but that's just my opinion.
Not sure , if it could help you . Check dataset option dbtype=(yourvarname char(200))
By default, Proc Import uses the first 20 rows of the dataset to determine the length of the variables. If your memo field doesn't have any content for the first few records, SAS might assume that the field is short. You can try using the guessingrows option in proc import to increase the number of rows SAS uses to determine the variable size. Just add the following statement somewhere after the import statement (I used 100 rows as an example, but this can be anything):
guessingrows=100;
If you really want to control the size of the variable, though, you'll probably have to use a data step instead of Proc Import.
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.