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
DiagonalI am modelling a huge database and I have to create a new variable that contains the value of the di…
Prior Event Rate Ratio (PERR) and its confidence intervalDear all, I am trying to calculate Prior Event Rate Ratio (PERR) and its 95% confidence interval in …
Logistic regression shows negative adj. (McFadden's) R2 but statistically sig. coefficient for main predictor variable. How to interpret?As the title says, I have a logistic regression model with a negative adjusted R2 (McFadden's), but …
Replacing missing value by linear intervals between tow points across time.Dear Statalist, I am current facing a bit of dilemma with missing variables. I have merge two datas…
OLS panel data regressionHi, I'm trying to run a regression with lots of controls. I'm looking for the impact of media on vot…
Subscribe to:
Post Comments (Atom)
0 Response to Combining codes of different do files
Post a Comment