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

I have a column in excel that exceeds 255.  When I read the data in and use dbsastype to force the column char and length, it still gives me 255.  Any ideas of what I'm doing wrong.

 

Here is some of the code:

 

LIBNAME WrkBk EXCEL "file" MIXED=YES;

DATA test.;
SET WrkBk."sh1"n(
DBSASTYPE=("f1"='char(450)'));
RUN;
LIBNAME WrkBk CLEAR;

1 ACCEPTED SOLUTION

Accepted Solutions
HN2001
Obsidian | Level 7
I ended up resorting back to a proc import statement and then setting the length in a data step that followed the proc import. From googling, I think there are limitations with the libname excel and libname xlsx.

View solution in original post

7 REPLIES 7
art297
Opal | Level 21

Have you tried it with dbms=xlsx. Unfortunately, it doesn't allow mixed and dbsastype, but often does what one wants. e.g.:

LIBNAME WrkBk xlsx "/folders/myfolders/book1.xlsx";

DATA test;
  SET WrkBk.sheet1;
RUN;

LIBNAME WrkBk CLEAR;

Art, CEO, AnalystFinder.com

 

 

HN2001
Obsidian | Level 7
I did try that and it didn't work. I needed to be able to set the length because I was reading in multiple files with a macro around that libname statement and of course the lengths in each file were different. I think there are limitations with xlsx and the length of the variable. I ended up reading in the data with a proc import and setting the length in a data step. Thanks for your suggestion
HN2001
Obsidian | Level 7
I agree I am definitely seeing limitations with libname excel and libname xlsx, even using proc import I see variations in how the data is read in with xlsx and excel
Ksharp
Super User

Try another option.

 

LIBNAME WrkBk EXCEL "file" MIXED=YES dbmax_text=32767 ;

DATA test;
SET WrkBk."sh1"n;
run;
HN2001
Obsidian | Level 7

Unfortunately that didn't work either

HN2001
Obsidian | Level 7
I ended up resorting back to a proc import statement and then setting the length in a data step that followed the proc import. From googling, I think there are limitations with the libname excel and libname xlsx.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 7 replies
  • 2366 views
  • 3 likes
  • 4 in conversation