BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Reader587
Calcite | Level 5

How to get SAS data into excel using different variable names?

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

A simple example

 

ods excel file="newfile.xlsx";
proc print data=sashelp.class(rename=(height=tallness weight=heaviness sex=gender));
run;
ods excel close;
--
Paige Miller

View solution in original post

5 REPLIES 5
ballardw
Super User

Please provide an example of your current variable names and what you expect the result to be.

andreas_lds
Jade | Level 19

Depends on the way you used to export the dataset. So please post the code you have, so that we can suggest something working in your setup.

Have a look at docs the rename-statement and/or the rename-option.

PaigeMiller
Diamond | Level 26

A simple example

 

ods excel file="newfile.xlsx";
proc print data=sashelp.class(rename=(height=tallness weight=heaviness sex=gender));
run;
ods excel close;
--
Paige Miller
Reeza
Super User
1. Use labels and export with the labels instead - usually just an option to set on your export.
2. Change the variable names with a RENAME statement as a data set option (see PaigeMilers solution)
3. Export as separate tables using PROC REPORT and the NOHEADER options (overkill by far)
Tom
Super User Tom
Super User

EXCEL files do not have variables. 

Are you asking how to make an Excel sheet with column headers that are different than the variable names in the source dataset?

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
  • 5 replies
  • 1096 views
  • 2 likes
  • 6 in conversation