Announcement

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

  • encoding variables, using in 'if' within 'metan' command

    I have a variable whose value is either 'yes', or 'no' ("g1schedule"), which was a sting, and I used 'encode'
    encode g1schedule, gen(schedule) The new variable "schedule" is still words, in blue now, not red like strings, which seems to be right, according to here: https://www.stata.com/support/faqs/d...ring-variable/

    However this variable wont work as a specification to work on only a subset of studies when using metan, as below:

    metan n mean SD n2 mean2 SD2 if schedule ==no, hedges
    no not found
    r(111);

    Variables work here (after 'if) when the value == a number, but not for those where it is a word, even after encoding.

    In case it helps:
    . describe schedule

    storage display value
    variable name type format label variable label
    ---------------------------------------------------------------------------------
    schedule long %8.0g schedule g1sleepschedule

    Does anyone know if there is something wrong with the variable, or the command syntax?

    Many Thanks!
    Sophie

  • #2
    One thing is the label, another thing is its value.

    You may type - codebook schedule -, then you get the values. Let's say "no" is equal to zero, then you type - if schedule ==0 - for that matter.

    Hopefully that helps.
    Best regards,

    Marcos

    Comment


    • #3
      Hi Marcos,

      That has worked. Thanks for your help, much appreciated

      Sophie

      Comment


      • #4
        Hello Sophie,

        Thank you for informing the thread reach a satisfactory closure to you.
        Best regards,

        Marcos

        Comment

        Working...
        X