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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.