DATA Step, Macro, Functions and more

rename statement

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

rename statement

Hello, all.  I am new to SAS but trying to understand the program syntax of some legacy SAS files.  This has to do with the rename statement. 

The very first lines in the program file look like this:

data mysetname (rename =

                         field1name     = newfield1name

                         field2name     = newfield2name

                         field3name     = newfield3name

                         this repeats for every field in the table, about 25 fields.

When would/why would you rename every field in a table?  These are the very first lines in the program and the first data set.  It doesn't look like there's any data transforming or calculations going on, just the renaming of the fields.  A best practice method?  Whoever wrote it did this each time they were defining a new data set.

Thanks in advance.


Accepted Solutions
Solution
‎07-30-2013 01:34 PM
Super User
Posts: 17,780

Re: rename statement

Without documentation best guesses:

  1. to match conventions, e.g the variable name match the names in another data source
  2. To merge back in later with a similar dataset to avoid name duplications
  3. To standardize code for a macro or old code to run, that was expecting certain variable names in the data set.
  4. More understandable names, gpc2342 means very little, but general_practitioner_south means way more.
  5. Cause...:smileylaugh:

View solution in original post


All Replies
Solution
‎07-30-2013 01:34 PM
Super User
Posts: 17,780

Re: rename statement

Without documentation best guesses:

  1. to match conventions, e.g the variable name match the names in another data source
  2. To merge back in later with a similar dataset to avoid name duplications
  3. To standardize code for a macro or old code to run, that was expecting certain variable names in the data set.
  4. More understandable names, gpc2342 means very little, but general_practitioner_south means way more.
  5. Cause...:smileylaugh:
Super User
Posts: 5,079

Re: rename statement

6. Because the boss said to do it that way.

7. Because the data is about to be downloaded to a spreadsheet and those are the column headings that the analyst wants.

Super User
Posts: 10,483

Re: rename statement

8. Didn't know how to use proc datasets to rename variables.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 230 views
  • 6 likes
  • 4 in conversation