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
Reduced sample size in time trends analysisHi, I have an indicator variable EventIndicator, which takes the value 1 if a firm is headquartered …
graph with range in x axisDear All, Suppose that I have this code Code: sysuse auto, clear twoway (scatter mpg weight if weig…
Using rangestat when there are gaps in the date identifierHi, I am trying to use rangestat to perform rolling regressions over a data panel. My data correspo…
How to create new variables using observations from other variable but observations contain spaces?I tried to use the following command to create new variables using observations from a variable "ind…
Moving vertical axis in graph hbarHi, I'm trying to plot a variable called "teleworking rate" by region. So my data looks like: tw_r…
Subscribe to:
Post Comments (Atom)
0 Response to Combining codes of different do files
Post a Comment