Announcement

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

  • Loop?

    I want to replicate this code up to stateid==32; from 1 to 32. How can I do this without typing it out 32 times. Do a loop?

    gen s1_trend = time if stateid==1
    recode s1_trend .=0

    gen s2_trend = time if stateid==2
    recode s2_trend .=0


    gen s3_trend = time if stateid==3
    recode s3_trend .=0

  • #2
    Code:
    forvalues x = 1/32 {
    gen s`x'_trend = time if stateid== `x'
    recode s`x'_trend .=0
    }

    Comment


    • #3
      much appreciated! thanks justin!

      Comment

      Working...
      X