As the title indicates I want to store a lot of variable names in a local, then use the local to produce summary statistics for the variables. This is because I have of lot of different summary statistics for a lot of variable which need to be produced for a lot of different subpopulations, and I don't want to type out the variables every times.
This is described in Stata Journal (2020): Speaking Stata: Loops, again and again, section 2.1. However, the code does not work for me. Executing:
Returns: `invalid name
I know there is a lot of errors due to the similarity between `, ', and ´, so I tried some different things, and it seems to work with `' instead of `´.
However, -tabstat- does not work with either, and that is the command I need to execute on a lot of variables in my specific problem:
line 3 returns: ` invalid name
line 4 returns: varlist required
line 5 returns: the desired results.
So how can I store variable names in a local and then use this local to produce summary statistics for the variables using -tabstat-? In case it is of any importance, my keyboard is Danish, my Office and Windows language is set to English, I am running SE 17.0 update level 10 Jan 2023, and using `' works perfectly fine when looping.
This is described in Stata Journal (2020): Speaking Stata: Loops, again and again, section 2.1. However, the code does not work for me. Executing:
Code:
sysuse auto local rhsvars "trunk weight length turn displacement" regress mpg `rhsvars´
I know there is a lot of errors due to the similarity between `, ', and ´, so I tried some different things, and it seems to work with `' instead of `´.
Code:
sysuse auto local rhsvars "trunk weight length turn displacement" regress mpg `rhsvars'
Code:
sysuse auto local rhsvars "trunk weight length turn displacement" tabstat `rhsvars´ tabstat `rhsvars' tabstat trunk weight length turn displacement
line 4 returns: varlist required
line 5 returns: the desired results.
So how can I store variable names in a local and then use this local to produce summary statistics for the variables using -tabstat-? In case it is of any importance, my keyboard is Danish, my Office and Windows language is set to English, I am running SE 17.0 update level 10 Jan 2023, and using `' works perfectly fine when looping.
Comment