How to Convert String Variables With Non-Numeric Values to Numeric Variables in Stata
How to Install Meta-Analysis Commands in Stata
User-written meta-analysis commands (e.g., metan, metafunnel) must be downloaded and installed to perform meta-analysis in Stata.
Stata, a statistical software package by StataCorp, boasts an impressive suite of meta-analysis features. metan is the Stata module for fixed and random effects meta-analysis. metafunnel “plots funnel plots: graphical displays used to examine whether the results of a meta-analysis may have been affected by publication or other types of bias.” These two commands do not come with Stata 10 by default; users of this and several subsequent versions of Stata have to download and install these user-written meta-analysis commands themselves.
Below, I summarize how I installed metan and metafunnel in Stata 10. Depending on your version of Stata, YMMV.
I used the guide available in Chapter 18 of Systematic Reviews in Health Care: Meta-Analysis in Context, 2nd Edition “Meta-analysis in Stata,” by Sterne, Bradburn, and Egger, but with minor changes and additions, which I will outline below.
Step 1: Update your installation of Stata.
. update all
Step 2: Install the user-written commands, e.g. metan, metafunnel.
I installed the commands from within Stata, i.e.
Help → SJ and User-written Programs → STB
You will see a list of Stata Technical Bulletins (stb) commands. I followed the instructions found in Sterne et al.’s guide:
In my Stata installation, I found the packages had an underscore, e.g., sbe24_1, instead of a decimal point, e.g., sbe24.1.
In addition, I installed the following metafunnel command within Stata by typing:
. ssc install metafunnel
This command enables the creation of funnel plots with pseudo 95% confidence limits.
Step 3: Check for updated versions or new commands:
. update all
. search metan
Having performed the steps above, I could not use the metan command to perform a fixed and random-effects meta-analysis. The problem was an old version of metan, specifically metan 1.0! You can check your version of metan:
. which metan
To update the version of metan, enter the following command on the Stata command line:
. ssc install metaaggr, all replace
Completing this last step enabled me to conduct a fixed and random-effects meta-analysis.
The steps above should not take longer than 5 minutes. Enjoy!
Thank you so much. My version of STATA stubbornly refused the commands I was entering!
Glad the article helped to solve your problem with Stata. Sometimes, it takes some trial and error and/or Googling. If those things don’t work, I’ll be happy to assist. 🙂
Hi,
I would like to thank you too. Thank you so much. My Stata also consistently rejected commands. The whole thing was to click “update all.” I have never thought the answer would be this easy.
Hello,
I tried all of these things, and STATA wont recognize the command. r199 keeps coming up and I have updated everything and added all the new commands.
Hello, I have installed the metan commands but how can i install follwoing commands
metacum
metainf
metabias
metareg
please guide me
Dr Shafi
@Dr Shafi – The information you’re seeking is found in Step 2 above. For example, to install
metacum
, first click on the “Help” tab within Stata, followed by “SJ and User-written Programs”, and then “STB”. Click on stb42, and then sbe22. You should be done!Hello,
Thanks for the info, though Im new to stata, I have always done analysis in SPSS, but recently need to perform a meta analysis. Any info to guide me through this especially being new to all the commands?
thanks
@lumen – I’m familiar with Stata but not SPSS. I’ve found short courses in Stata quite useful because the learning is guided and you are able to get feedback – see https://www.stata.com/learn/ . There are books on using Stata but I have rarely found them of much help.
Hello,
I have followed as your recommendation.
However, I can still see the sign of “unrecognized command”.
What might be the problem?
@Kyoungjune – It could be related to a later version of Stata – the instructions above apply to Stata 10.
great !! thanks a lot
Dear Andy Teh,
I have followed the steps as you mentioned. I have the metan 1.0 version (*! version 1.0 5May98 STB-44 sbe24). When I try to write ‘scc install metaaggr, all replace’ command, my STATA says:
“scc install metaaggr, all replace
unrecognized command: scc
r(199);”
I have a MacBook, but the STATA version i fully compatible. Do you know why the command does not work?
@Ulrich – I’m not sure if the problem is due to your version of Stata (I used version 10) or the fact you’re on a Mac operating system (I use Linux), or something else. The steps above have generally been replicable by those with the same setup as mine.
Thanks a lot for the advice! I followed the steps and updated the stata 12 I am using. However, in meta regression analysis, the output doesn’t give the following results:-
-REML estimate of between study variance
-The between study variance explained (Adj-R squared)
-Joint test for all covariates.
Thanks a lot for this very helpful advice! Worked perfectly for me!
You are a HERO! This needs to be repeated- You sir, are a HERO! Thanks a ton! 😀
Andy Teh,
You are super.
How to run metaregression?
Dr Andy Teh
I need to run metaregression. I tried sometimes, but I have no success.
I believe that I do not know how to insert data in STATA. Could you send me one picture or a guide showing how I can do this?
Thank you
I am so so thankful for your great summary. You saved my life 🙂
Hi, I am using stata from server of the UNSW. I need to run stata on my computer but it seems it not allow me to install. Could you please show me the way to install it? I found last time that I need to change the directory but I forgot. Thanks for your help!
@Diep – I’m sorry I don’t provide support for the installation of Stata. I suggest you reach out to your university’s IT Department for help.