Julia
Julia

Reputation: 37

Change multiple consecutive variable names

I am using Stata 14 and have a dataset which contains a large group of variables:

court_date1 court_date2 court_date3

I would like to change part of each variable name while keeping the number at the end:

court_event1 court_event2 court_event3

Is there a way to do so as a group using the wildcard (*)? They are numbered consecutively, but are not listed consecutively in the dataset.

Upvotes: 0

Views: 127

Answers (1)

Nick Cox
Nick Cox

Reputation: 37183

rename (*date*) (*event*) 

works with just the names you give. If that catches too much, then

rename (court_date*) (court_event*) 

See help rename groups, including the dryrun option.

Upvotes: 2

Related Questions