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

I'm using this code to export labeled SAS data to Excel spreadsheets:

 

libname xlout xlsx "&root.\dataData\file.xlsx";
data xlout.data;
	set tables.data;
run;
libname xlout clear;

 The result, however,  is an Excel file with SAS variable names (e.g. dob) instead of variable labels (e.g. Date of Birth) as the column names. I would prefer having the SAS labels instead. Is this possible with libname xlsx?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

No.  Use ODS EXCEL.

ods excel file="&root.\dataData\file.xlsx";
ods excel options (sheet_name="data");
proc print noobs label data=tables.data;
run;
ods excel close;

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

No.  Use ODS EXCEL.

ods excel file="&root.\dataData\file.xlsx";
ods excel options (sheet_name="data");
proc print noobs label data=tables.data;
run;
ods excel close;
Ksharp
Super User
data have;
 set sashelp.class;
 label sex='ssssss' name='nnnnnnnnnn';
run;

proc export data=have outfile='c:\temp\temp.xlsx' dbms=xlsx replace label;
run;

Or PROC EXPORT.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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