I am trying to run the codes of two separate do files, combining them into the same do files. Each do file is taking data from different file directories. If I can get both codes to once, I will then combine data and variables before running a regression
The codes for the two do files I am trying to combine are:
clear all
cd "G:\Shared drives\SE475 Capstone, Dennis Evans\State Data - Last 5 Years"
foreach num of numlist 1 / 51 {
import delimited `num'.csv, clear
rename v1 week
rename v2 interest
gen state = `num'
save S`num'.dta, replace
}
use S1.dta, clear
foreach num of numlist 2 / 51 {
append using S`num'.dta
}
save search_data.dta, replace
use search_data.dta
gen weekly_date = date(week, "MDY")
format weekly_date %td
drop week
collapse interest, by(state weekly_date)
sort weekly_date state
rename state statenum
browse
------------------------------------------------
clear all
cd "G:\Shared drives\SE475 Capstone, Dennis Evans\COVID Infection Rate Data"
foreach num of numlist 1 / 51 {
import delimited `num'.csv, clear
gen statenum = `num'
save Covid`num'.dta, replace
}
use Covid1.dta, clear
foreach num of numlist 2 / 51 {
append using Covid`num'.dta
}
gen weekly_date = date(date, "MDY")
format weekly_date %td
qui gen dow = dow(weekly_date)
qui gen week_no = wofd( weekly_date)
qui gen temp = date if dow == 0
by week_no, sort: egen week_var = mode(temp)
collapse totalcaserateper100k, by(week_var statenum)
gen weekly_date = date(week_var, "MDY")
format weekly_date %td
sort weekly_date statenum
drop week_var
order weekly_date, before(totalcaserateper100k)
save covid_data.dta, replace
*use covid_data.dta
*xtset statenum weekly_date
browse
Related Posts with Combining codes of different do files
adding zeros before the valueHello, I have this dataset and want to add 0s to before Company if the Company length is less that 6…
Facing Heteroscadcity in unbalanced panel dataHi There are two models. Data taken from only 1 country and there are 25 institutes. total observati…
estimated values by margins after mixed vs. observed values by sumHi, Here is the data set I am analyzing. It is in a long format: 3-time points (time=1, 2, and 3 ) …
Obtaining the 95% confidence interval overlapHi, My actual dataset includes my quantities of interest (A, B, C, and D) obtained from 1000 bootstr…
Difference in cumulative incidence and confidence intervalI want to compare cumulative incidence for two arms of a cohort at time _t and generate confidence i…
Subscribe to:
Post Comments (Atom)
0 Response to Combining codes of different do files
Post a Comment