BookmarkSubscribeRSS Feed
ducdien
Calcite | Level 5

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

10 REPLIES 10
ballardw
Super User

It will help to show the code used.

ducdien
Calcite | Level 5

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

ballardw
Super User

What do you get when you run proc contents on the dataset Test?

ducdien
Calcite | Level 5

When I run proc content, those variables show up as "Char, length 3, format $3, informat $3"

ballardw
Super User

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.

ducdien
Calcite | Level 5

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

ducdien
Calcite | Level 5

Any suggestions on this?

Thank you

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Ksharp
Super User

Not sure , if it could help you .    Check dataset option     dbtype=(yourvarname char(200))

ebowen
Quartz | Level 8

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 10 replies
  • 1771 views
  • 0 likes
  • 5 in conversation