Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mean using "if" with string variables

    A colleague used the exact code below to run a meta-analysis with the if statement being string variables, however when I run the code I get an error message "mean_temp not found, r(111)".

    code: metan lnor selnor if exposure== "mean_temp", random by(lag) label(namevar = health_unit) eform nooverall title(Mean Temperature)

    I then tried using encode to turn the string variables in categories but then I relieve the error "too few variables specified, r(102)"

    Please help

  • #2
    Welcome to Statalist.

    I suspect the command you ran was
    Code:
    metan lnor selnor if exposure== mean_temp, random by(lag) label(namevar = health_unit) eform nooverall title(Mean Temperature)
    without the quotation marks around mean_temp that you show above, because Stata is telling you that it is looking for a variable named mean_temp, and cannot find it in your dataset.

    Based on your code, I am assuming you have a string variable named exposure, which takes values that include "mean_temp", and you want to run your metan command on only those observations where exposure has the value "mean_temp".

    But perhaps I misunderstand what your data and commands were like. Please take a few moments to review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question. It's particularly helpful to copy commands and output from your Stata Results window and paste them into your Statalist post using code delimiters [CODE] and [/CODE], and to use the dataex command to provide sample data, as described in section 12 of the FAQ.

    The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

    Comment

    Working...
    X