Announcement

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

  • #16
    Originally posted by Kyle Smith View Post

    Would you know how to split the range into 2 variables: give the start year a variable and the end year a different variable? Instead of saying foreach period in...., if we could say foreach period1,period2 in... I think my issue would be resolved.
    Code:
    webuse grunfeld, clear
    
    local i 0
    foreach period in 1940,1940 1954,1954 {
        regress invest mvalue if inrange(year,`period')
        local opt= cond(`i'==0, "replace", "append")
        outreg2 using myfile.xls, `opt' addtext(StartYear, "`=substr("`period'", 1, 4)'",EndYear, "`=substr("`period'", -4, 4)'") excel
        local ++i
    }
    Res.:

    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	61.5 KB
ID:	1766910


    Comment

    Working...
    X