I have many variables that need to be reshaped from wide form to long form. Each is the name of a county and the values represent the population at different age groups. Before reshaping this data (from Counties in columns to columns in rows) I need to give them all an identical prefix. I would like to simply add "pop" to the front of all the County variable names. I can do this individually using:
rename County1 popCounty1
but this would take a very long time. I have tried several methods for doing this for a long list of variables without success. My most recent attempt included using the renvars command as follows:
renvars CountyVariablesList prefix(pop)
and was given the error "factor variables and time-series operators not allowed"
I've also tried using rename as follows:
rename CountyVariablesList pop=:
but I think I'm interpreting the help guide wrong on this one. It says:
rename whatever pre=fix: Adds prefix pre and suffix fix to all variables selected by whatever. & that "whatever is specified" -- > I'm not sure how to specify "whatever" other than listing the variables I want to update.
Any help would be much appreciated, thanks!
rename County1 popCounty1
but this would take a very long time. I have tried several methods for doing this for a long list of variables without success. My most recent attempt included using the renvars command as follows:
renvars CountyVariablesList prefix(pop)
and was given the error "factor variables and time-series operators not allowed"
I've also tried using rename as follows:
rename CountyVariablesList pop=:
but I think I'm interpreting the help guide wrong on this one. It says:
rename whatever pre=fix: Adds prefix pre and suffix fix to all variables selected by whatever. & that "whatever is specified" -- > I'm not sure how to specify "whatever" other than listing the variables I want to update.
Any help would be much appreciated, thanks!
Comment