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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 220 views
  • 0 likes
  • 2 in conversation