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

Hi, there

When I use the libref with xlsx engine to access the data, I couldn't get all the variables.

x "&pout.vardict.xlsx";

Capture.JPG

 

If I access the data

libname templib xlsx "&pout.vardict.xlsx";
proc sql;
    select name
    from dictionary.columns 
    where libname="TEMPLIB";
quit;

the variable description was disappeared

Capture.JPG

Although I can use other approaches to read the data, I want to know what is wrong.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
su35
Obsidian | Level 7
Thanks replies,
According to ballardw's remending, I save the xlsx file to csv file, and re-save the csv file to xlsx file. Then the problem gone

View solution in original post

4 REPLIES 4
ballardw
Super User

What is your setting for VALIDVARNAME?

Does the source file have any merged cells in the column header? Hidden columns?

 

I am not sure how well the dictionary tables work with some of the stuff that appears in Excel. You may need to copy the sheet to an actual SAS data set to get a better idea of the contents.

RichardDeVen
Barite | Level 11

What version of SAS are you using ?

 

I find your assertion is incorrect for my installation.

 

This example demonstrates creating a worksheet that has a column named "description", and when read via the XLSX engine the description column is present in the metadata table DICTIONARY.COLUMNS result set.

 

data have;
  length variable $32 type 8 class $8 length apply id 8 description $200;
  input (variable--description) (&);
datalines;
fubar  1  magic  2  3  4  This is fubar check  
run;

proc export data=have dbms=xlsx replace file='c:\temp\mighty-data.xlsx';
run;

libname checkxl xlsx 'c:\temp\mighty-data.xlsx'; 


ods html file='xlsx-lib-meta.html' style=plateau;
proc sql;
  select * from dictionary.columns
  where libname='CHECKXL'
  ;
ods html close;

proc sql;


libname checkxl;

%sysexec start "auto launch" "c:\temp\mighty-data.xlsx";

Perhaps your description column is empty in a way that prevents the engine from processing it (i.e. consider the speculation that the engine thinks your description column is width 0 and discards it)

su35
Obsidian | Level 7
Thanks replies,
According to ballardw's remending, I save the xlsx file to csv file, and re-save the csv file to xlsx file. Then the problem gone

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
  • 4 replies
  • 806 views
  • 0 likes
  • 4 in conversation