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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 5 replies
  • 1404 views
  • 2 likes
  • 6 in conversation