Hello everyone,
I am currently working on a data set that has both a year variable along with pertinent IV and DV variables. Since I want to make suggestions about causality, this means that I need to transform some of my variables by year. I have done so, however, now I'm not sure if I did so correctly.
In this regard, I am needing to run SEM- but when I do so, I get a 'no observations found' error. I suspect it has something to do with my coding and utilization of the year variable.
Is there some other code I can use, such as doing sem with an if command? I have not done this before so wondering if there are alternatives.
Here is my code for what I have done as an example:
*make carsi for 2011
gen carsi_2011=.
replace carsi_2011=0 if carsi==0 & year==2011
replace carsi_2011=1 if carsi==1 & year==2011
label values carsi_2011 label_carsi
sort country
by country: tab carsi_2011 year, miss
*MAKE FOR >=2012
gen disorg9_2012=.
replace disorg9_2012=0 if disorg9==0 & year>=2012
replace disorg9_2012=1 if disorg9==1 & year>=2012
replace disorg9_2012=2 if disorg9==2 & year>=2012
replace disorg9_2012=3 if disorg9==3 & year>=2012
replace disorg9_2012=4 if disorg9==4 & year>=2012
tab disorg9_2012 disorg9, miss
tab disorg9_2012 year, miss
tab disorg9_2012 country, miss
*>=2012
gen soco1_2012=.
replace soco1_2012=0 if mysoco1==0 & year>=2012
replace soco1_2012=1 if mysoco1==1 & year>=2012
replace soco1_2012=2 if mysoco1==2 & year>=2012
replace soco1_2012=3 if mysoco1==3 & year>=2012
tab soco1_2012 country, miss
tab soco1_2012 year, miss
label values soco1_2012 label_soco
sem (CE -> soco1_2012) (CE -> soco2_2012) (CE -> soco3_2012) (Disorg -> disorg9_2012) (Disorg -> disorg10_2012) (Disorg -> disorg15_2012) (Disorg -> disorg17_2012) (Disorg -> disorg18_2012) (carsi_2011 -> CE) (carsi_2011 -> Disorg)
Related Posts with Having time-specific control and IV variables
Difficulty with egenHi all, I usually have no problem with egen but I am finding it impossible to complete a relatively…
panel unit root test fixed effect random effect1. In what bases of Unit root test result I can go for fixed and random effect modelling? 2. Can I g…
Change in a variable when we have pooled cross-sectionsHello, How can we calculate the change in a variable when its values for two consecutive years are …
Problem with the Stata GraphHey guys, I'm quit new to Stata and want to give out a graph in Stata. I have import and export Dat…
Finding the game that your friend also play for network analysisHello, statalist community! Currently I am trying to manipulate my dataset so that I can use it to …
Subscribe to:
Post Comments (Atom)
0 Response to Having time-specific control and IV variables
Post a Comment