Hi,

I am using Stata 17 and would help in producing tables in all my dataframes. Below is an example of my dataset:

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str3 location str7 time float unemp_data byte(pt_output recessions)
"AUS" "1966-Q3"      1.8 . 1
"AUS" "1966-Q4"      1.7 . 1
"AUS" "1967-Q1"      1.8 . 1
"AUS" "1967-Q2"        2 . 1
"AUS" "1967-Q3"      1.9 . 1
"AUS" "1967-Q4"      1.8 . 1
"AUS" "1968-Q1"      1.9 . 1
"AUS" "1968-Q2"      1.9 . 1
"AUS" "1968-Q3"      1.8 . 1
"AUS" "1968-Q4"      1.7 . 1
"AUS" "1969-Q1"      1.8 . 1
"AUS" "1969-Q2"      1.8 . 1
"AUS" "1969-Q3"      1.7 . 1
"AUS" "1969-Q4"      1.9 . 1
"AUS" "1970-Q1"      1.6 . 1
"AUS" "1970-Q2"      1.7 . 1
"AUS" "1970-Q3"      1.7 . 1
"AUS" "1970-Q4"      1.6 . 1
"AUS" "1971-Q1"      1.7 . 1
"AUS" "1971-Q2"      1.9 . 1
"AUS" "1971-Q3"      1.9 1 1
"AUS" "1971-Q4"      2.2 . 1
"AUS" "1972-Q1"      2.4 2 1
"AUS" "1972-Q2"      2.4 . 1
"AUS" "1972-Q3"      2.9 . 1
"AUS" "1972-Q4"      2.8 . 1
"AUS" "1973-Q1"      2.6 . 1
"AUS" "1973-Q2"      2.3 . 1
"AUS" "1973-Q3"      2.1 . 1
"AUS" "1973-Q4"      2.1 . 1
"AUS" "1974-Q1"      2.1 . 1
"AUS" "1974-Q2"      2.1 . 1
"AUS" "1974-Q3"      2.7 . 1
"AUS" "1974-Q4"        4 . 1
"AUS" "1975-Q1"      4.8 . 1
"AUS" "1975-Q2"      4.8 1 1
"AUS" "1975-Q3"      4.7 . 1
"AUS" "1975-Q4"      5.4 2 1
"AUS" "1976-Q1"      4.9 . 1
"AUS" "1976-Q2"      4.5 . 1
"AUS" "1976-Q3"      4.8 . 1
"AUS" "1976-Q4"      4.9 . 1
"AUS" "1977-Q1"      5.2 . 1
"AUS" "1977-Q2"      5.6 1 1
"AUS" "1977-Q3"      5.8 . 1
"AUS" "1977-Q4"      5.9 2 1
"AUS" "1978-Q1"      6.6 . 1
"AUS" "1978-Q2" 6.260822 . 1
"AUS" "1978-Q3" 6.322245 . 1
"AUS" "1978-Q4" 6.301046 . 1
end
I have used these codes to produce dataframes of all countries and their regressions:

Code:
gen quarters = quarterly(time, "yq")
format quarters %tq

//create dataframes of countries
** create all country dataframes with one command
levelsof location, local(location_list)
foreach loc of local location_list {
    frame put location time unemp_data pt_output recessions quarters if location=="`loc'", into (`loc'_dataset)
}

levelsof location, local(location_list)
foreach loc of local location_list {
    frame `loc'_dataset {
        tsset quarters
        gen P_unemp = unemp[_n+12] - unemp
    }
    
}

levelsof location, local(location_list)
foreach loc of local location_list {
    frame `loc'_dataset {
        reg P_unemp unemp
        outreg2 using table_`loc',word
    }
    
}


levelsof location, local(location_list)
foreach loc of local location_list {
    frame `loc'_dataset {
        sqreg P_unemp unemp , quantiles(0.1 0.5 0.9) reps(200)
        outreg2 using table_`loc'_quantile,word
    }
    
}

My intention is to produce word documents for all dataframes. Unfortunately my codes only produce word document of the current frame.

How does one modify the codes to produce word documents of all dataframes?

Any help in this area would be appreciated. Thanks!