Hi everyone,
This might have a simple solution but I'm stuck.
I have a set of variables that goes like qn2_2__10 qn2_3__10 qn2_3a__10 head__10 qn2_4__10 qn2_5__10 qn2_6__10 qn2_8__10 qn2_9__10 qn2_10__10
I want to remove one space i.e. "_" from these variables (eg change qn2_2__10 to qn2_2_10) and the command rename *_# *#works but it removes one space "_" for all the variables in my dataset. Is there a way I can limit it to only the required variables?
I thought I may get lucky by using a loop (below) but it also performed the change in the whole dataset.
foreach var of varlist qn2_2__10-qn2_10__10 {
rename *_# *#
}
Related Posts with Removing middle character from a set of variables
Running pairwise correlation with both categorical and continuous variablesDear All, I need to look at the pairwise correlation with both categorical and continuous variables…
calculate APCs, CIs and p-values for the trend of APC using Poisson regressionHi everybody, I am new to Poisson regression. And I have 20-year age-standardized incidence rates f…
Calculation of Potential impact faction (PIF)Is there any Stata package for estimating PIF. I am aware of a few packages for PAF, but not finding…
Creating State variables from city codesDear All, I am trying to create a new "state" variable from certain city codes, one can observe tha…
Moderator and Independent Variable using Dummy (Binary Variable)Hi Stata Experts Team, I would like to know whether there is a different procedure in regression if…
Subscribe to:
Post Comments (Atom)
0 Response to Removing middle character from a set of variables
Post a Comment