I would like to add a prefix or suffix to all variables which do not begin with x:
clear
input xa xb c d
1 1 1 1
end
I thought something like this: rename (!x)* y* which should give this result: xa xb yc yd.
Thanks for any hint.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is not ideal in my mind, but off the top of my head, perhaps something like
renpfixmight be of use to you:Here, I’ve first added a prefix to all the variables, thus resulting in your first two variables having a prefix of
yx; then I’ve replaced theyxprefix to get back toxfor the first two variables.Update
Another option is to use
dsorfindname(install usingsearch findname) and using thenotargument to negate the matched variablesdsandfindnamestore their results in`r(varlist)', so you can useforeachafter identifying the relevant variables.