BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
orchid_sugar
Fluorite | Level 6

I have a dataset with labels that I want to export to excel, but the label statement won't turn blue or export the label. 'About SAS 9' indicates I have SAS 9.4 TS Level 1M5, so the label statement should work... putnames doesn't work either. I tried to rename the variable itself, but they contain special characters (e.g. #). How can I export the dataset to excel with labels?

proc export 
	data=missingReport 
	outfile="C:location\filename.xlsx" 
	dbms=xlsx
	label replace;
	sheet="missingFacilities";
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Works fine for me:

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

proc export label data=class dbms=xlsx
  file='c:\downloads\labels.xlsx' replace;
run;

Tom_0-1713314565915.png

 

Make sure to attach the labels BEFORE the PROC EXPORT step.

You don't have to make a copy of the dataset, you can use PROC DATASETS to modify the labels without copying the dataset.

 

If the variable names do not meet SAS naming rules then you will need to use name literals in the LABEL statement.

label 'job#'n ='Job Number';

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

Works fine for me:

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

proc export label data=class dbms=xlsx
  file='c:\downloads\labels.xlsx' replace;
run;

Tom_0-1713314565915.png

 

Make sure to attach the labels BEFORE the PROC EXPORT step.

You don't have to make a copy of the dataset, you can use PROC DATASETS to modify the labels without copying the dataset.

 

If the variable names do not meet SAS naming rules then you will need to use name literals in the LABEL statement.

label 'job#'n ='Job Number';

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

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
  • 1 reply
  • 532 views
  • 0 likes
  • 2 in conversation