Announcement

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

  • Stratification

    Hello,

    I am trying to create a Table in which you will see positive results (Serum=2) by age group ( agegroup = 1 and then 2, 3, etc...).
    This is the first line of my code:

    gen agegrouppositive= 1 if agegroup=1 & Serum=2

    The syntax is invalid!
    Can someone explain why? Can you help me? Thanks in advance


    agegroup | Freq. Percent Cum.
    ------------+-----------------------------------
    1 | a f k
    2 | b g
    3 | c h l
    4 | d i m
    5 | e j 100.00
    ------------+-----------------------------------
    Total | x 100.00



    Serum | Freq. Percent Cum.
    ------------+-----------------------------------
    1 | a c e
    2 | b d f
    ------------+-----------------------------------
    Total | g 100.00


  • #2
    Dear Max,

    You must use two equal signs instead of one when using logic in Stata. Your code should instead look like this:

    gen agegrouppositive = 1 if agegroup == 1 & Serum == 2

    I believe this is why your code is returning an error.

    Best,
    Salvatore

    Comment


    • #3
      Dear Salvatore Viola,

      you are a genius. It works.

      Thank you very much!

      Comment

      Working...
      X