BookmarkSubscribeRSS Feed
xxformat_com
Barite | Level 11

Hi,

I was wondering on whether there is any option which can be used with the xlsx engine to keep variable labels in export files as does the label option of proc export.

I know that dblabel can be used with the excel engine but what about the xlsx engine?

 


data class;
    set sashelp.class;
    label name='First Name';
run;

libname test xlsx "&xxtest/test_libname.xlsx";

data test.class;
    set class;
run;

libname test;

proc export data    = class
            dbms    = xlsx
            outfile = "&xxtest./test_procexport.xlsx"
            replace
            label;
run;
7 REPLIES 7
PaigeMiller
Diamond | Level 26

It looks like you have the code to try it. Why don't you try it and see what happens?

--
Paige Miller
xxformat_com
Barite | Level 11

I don't know any option which work with the xlsx engine using the libname statement.

My question is on whether someone knows an option I would not aware of.

PaigeMiller
Diamond | Level 26

What happens when you execute the code you show. Do the labels appear, or not?

--
Paige Miller
xxformat_com
Barite | Level 11
only proc export uses the label, not the other methods. But I'm not sure why you're asking it as I've already specify it in my question.
Reeza
Super User

Not sure what you're trying to do overall, but ODS EXCEL can split a file into two using BY as sheet_interval and then proc print with a label. 

 

proc sort data=sashelp.class out=class;
by sex;
run;

ods excel file='/home/fkhurshed/test.xlsx' options(sheet_interval = 'bygroup') style=minimal;
options nobyline;
proc print data=class noobs;
by sex;
run;

proc print data=class label noobs;
label age = 'Age (years)' weight = 'Weight (lbs)' height = 'Height (in)';
run;

ods excel close;

 

 

Tom
Super User Tom
Super User

Why not just try it?

602
603  libname x xlsx "C:\downloads\test_labels.xlsx" ;
NOTE: Libref X was successfully assigned as follows:
      Engine:        XLSX
      Physical Name: C:\downloads\test_labels.xlsx
604  data x.datastep(dblabel=yes); set class ; run;
                     -------
                     22

ERROR 22-7: Invalid option name DBLABEL.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


605  libname x clear;
NOTE: Libref X has been deassigned.

Looks like the answer is NO.

 

So use PROC EXPORT.

Or ODS EXCEL;

ods excel file= "C:\downloads\test_labels.xlsx" ;
proc print data=class label;
run;
ods excel close;
xxformat_com
Barite | Level 11
I was wondering on whether other options than the one I mentioned in my question could exist but I would not be aware of. db... options are for excel not for xlsx.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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