Hi,

I am pretty new in using data frames. I intend to execute commands on all frames after creating them. I understand there is a code for specific frame:

Code:
 frame framename: stata_command
Is there any code for executing commands for all frames? My plan is to create all the frames I need and then proceed to execute commands on all frames. If I don't have a code for that, I may have to have multiple lines to execute commands on each frame manually. Below is an example of my dataset:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str3 location str7 time float unemp_data byte pt_output float(spell quarters_to_start)
"AUS" "1966-Q3"      1.8 . 0  20
"AUS" "1966-Q4"      1.7 . 0  20
"AUS" "1967-Q1"      1.8 . 0  20
"AUS" "1967-Q2"        2 . 0  20
"AUS" "1967-Q3"      1.9 . 0  20
"AUS" "1967-Q4"      1.8 . 0  20
"AUS" "1968-Q1"      1.9 . 0  20
"AUS" "1968-Q2"      1.9 . 0  20
"AUS" "1968-Q3"      1.8 . 0  20
"AUS" "1968-Q4"      1.7 . 0  20
"AUS" "1969-Q1"      1.8 . 0  20
"AUS" "1969-Q2"      1.8 . 0  20
"AUS" "1969-Q3"      1.7 . 0  20
"AUS" "1969-Q4"      1.9 . 0  20
"AUS" "1970-Q1"      1.6 . 0  20
"AUS" "1970-Q2"      1.7 . 0  20
"AUS" "1970-Q3"      1.7 . 0  20
"AUS" "1970-Q4"      1.6 . 0  20
"AUS" "1971-Q1"      1.7 . 0  20
"AUS" "1971-Q2"      1.9 . 0  20
"AUS" "1971-Q3"      1.9 1 1  15
"AUS" "1971-Q4"      2.2 . 1  15
"AUS" "1972-Q1"      2.4 2 1  15
"AUS" "1972-Q2"      2.4 . 1  15
"AUS" "1972-Q3"      2.9 . 1  15
"AUS" "1972-Q4"      2.8 . 1  15
"AUS" "1973-Q1"      2.6 . 1  15
"AUS" "1973-Q2"      2.3 . 1  15
"AUS" "1973-Q3"      2.1 . 1  15
"AUS" "1973-Q4"      2.1 . 1  15
"AUS" "1974-Q1"      2.1 . 1  15
"AUS" "1974-Q2"      2.1 . 1  15
"AUS" "1974-Q3"      2.7 . 1  15
"AUS" "1974-Q4"        4 . 1  15
"AUS" "1975-Q1"      4.8 . 1  15
"AUS" "1975-Q2"      4.8 1 2   8
"AUS" "1975-Q3"      4.7 . 2   8
"AUS" "1975-Q4"      5.4 2 2   8
"AUS" "1976-Q1"      4.9 . 2   8
"AUS" "1976-Q2"      4.5 . 2   8
"AUS" "1976-Q3"      4.8 . 2   8
"AUS" "1976-Q4"      4.9 . 2   8
"AUS" "1977-Q1"      5.2 . 2   8
"AUS" "1977-Q2"      5.6 1 3  17
"AUS" "1977-Q3"      5.8 . 3  17
"AUS" "1977-Q4"      5.9 2 3  17
"AUS" "1978-Q1"      6.6 . 3  17
"AUS" "1978-Q2" 6.260822 . 3  17
"AUS" "1978-Q3" 6.322245 . 3  17
"AUS" "1978-Q4" 6.301046 . 3  17
"AUS" "1979-Q1" 6.310916 . 3  17
"AUS" "1979-Q2" 6.318468 . 3  17
"AUS" "1979-Q3" 6.209076 . 3  17
"AUS" "1979-Q4" 6.184022 . 3  17
"AUS" "1980-Q1" 6.027812 . 3  17
"AUS" "1980-Q2"  6.22865 . 3  17
"AUS" "1980-Q3" 6.132486 . 3  17
"AUS" "1980-Q4" 5.986451 . 3  17
"AUS" "1981-Q1" 5.760276 . 3  17
"AUS" "1981-Q2" 5.506487 . 3  17
"AUS" "1981-Q3" 5.829319 1 4  37
"AUS" "1981-Q4" 5.965766 . 4  37
"AUS" "1982-Q1" 6.205254 . 4  37
"AUS" "1982-Q2" 6.565073 . 4  37
"AUS" "1982-Q3" 7.108994 . 4  37
"AUS" "1982-Q4" 8.792985 . 4  37
"AUS" "1983-Q1" 9.637337 . 4  37
"AUS" "1983-Q2" 10.22675 2 4  37
"AUS" "1983-Q3" 10.35557 . 4  37
"AUS" "1983-Q4" 9.707231 . 4  37
"AUS" "1984-Q1" 9.364694 . 4  37
"AUS" "1984-Q2" 9.134859 . 4  37
"AUS" "1984-Q3" 8.824427 . 4  37
"AUS" "1984-Q4" 8.631944 . 4  37
"AUS" "1985-Q1"  8.53574 . 4  37
"AUS" "1985-Q2" 8.450373 . 4  37
"AUS" "1985-Q3" 8.171014 . 4  37
"AUS" "1985-Q4" 7.861616 . 4  37
"AUS" "1986-Q1" 7.912621 . 4  37
"AUS" "1986-Q2"  7.80089 . 4  37
"AUS" "1986-Q3" 8.230766 . 4  37
"AUS" "1986-Q4" 8.330906 . 4  37
"AUS" "1987-Q1" 8.278452 . 4  37
"AUS" "1987-Q2"  8.17074 . 4  37
"AUS" "1987-Q3" 7.980749 . 4  37
"AUS" "1987-Q4" 7.915184 . 4  37
"AUS" "1988-Q1" 7.518405 . 4  37
"AUS" "1988-Q2" 7.644826 . 4  37
"AUS" "1988-Q3" 6.921671 . 4  37
"AUS" "1988-Q4" 6.754443 . 4  37
"AUS" "1989-Q1" 6.595482 . 4  37
"AUS" "1989-Q2" 6.164414 . 4  37
"AUS" "1989-Q3" 6.007802 . 4  37
"AUS" "1989-Q4" 5.853007 . 4  37
"AUS" "1990-Q1" 6.230017 . 4  37
"AUS" "1990-Q2" 6.464528 . 4  37
"AUS" "1990-Q3" 7.225374 . 4  37
"AUS" "1990-Q4" 7.867509 1 5 120
"AUS" "1991-Q1" 8.732559 . 5 120
"AUS" "1991-Q2" 9.633936 2 5 120
end
This is my method of creating a frame:
Code:
frame put location time unemp_data pt_output if location=="AUS", into (aus_dataset) //  input aus dataset into another dataframe
This is for Australia data frame. I am not too sure if there are ways to automate this process. I mean, if my dataset happens to be have 30 countries, I would need to have 30 lines of this code in order to have 30 data frames.


After the creation of the frames, I intend to use the following codes on all frames:

Code:
by location (time), sort: gen spell = sum(pt_output == 1) //spell = {0,1,2,3,4,5}

I am using Stata 16, any help would be appreciated to automate the process. Thanks!