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
How to select the observation with a date that is closest to another date in STATAI have multiple blood test results for single pregnancies and wish to select the blood test result t…
Online courses/Summer school to learn STATAHello, I am looking for a short courses during the summer in Europe to learn some knowledge using S…
Matching Weights Approach (Propensity Score Analysis)Hi, I was wondering if someone has already used the matching weights approach described by Li and G…
performance comparison between NLS and GMMHello, In the last few weeks I have compared the performance of the -nl and -gmm commands since I a…
Creating indicator variables xi, prefix() for an interaction termHi STATA friends, I aim to generate indicator variables regarding the interaction term c.budgetbala…
Subscribe to:
Post Comments (Atom)
0 Response to Combining codes of different do files
Post a Comment