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
Putexcel: More of two decimal in putexcelHi! I have a problem with the next code : Code: * I need more of two decimal in the next test: s…
Random Effect or Mixed effect model for Panel DataDear Statalist, I want to estimate the effect of endowment, netprice, religiosity and knowledge on c…
egen or gen newvar to categorize the 50 states into Democrat, Republican, or Swing based on 2016 election resultsHi y'all I would be most grateful if anyone out there has written a simple code to categorize states…
Changing SIF DMYhms Time Variables to DMY Time VariablesI seek to geospatially merge some rainfall data with a master dataset. Before I can do that though, …
Egen or gen newvar to categorize the 50 states into Democrat, Republican, or Swing based on 2016 election resultsHi y'all I would be most grateful if anyone out there has written a simple code to categorize states…
Subscribe to:
Post Comments (Atom)
0 Response to Having time-specific control and IV variables
Post a Comment