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?
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;
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;
Thank you.
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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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 save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.