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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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