I am trying to generate lots of interactions, which I will then filter in order to eliminate near-empty cells. I can't use the usual factor-variable syntax with the command that I am interested in (lasso), because the result would be 16,000 interactions, many of which involve very few observations. In fact, I tried it, and the program ran for hours and then hung, first on my laptop, then on a pretty muscular server. So here is what I did and the interaction variables that got created:
As you can see, the loops only acted on the last elements in the respective macros. What am I doing wrong?
Code:
. local qtest "question1 question2"
. local chtest "dcount_da_cat dcount_dacrime_cat"
. foreach q of local qtest {
2. foreach v of local chtest {
3. xi i.`q'*i.`v',noomit
4. }
5. }
i.qu~n1*i.dco.. _IqueXdco_#_# (coded as above)
i.qu~n1*i.dco.. _IqueXdco_#_# (coded as above)
i.qu~n2*i.dco.. _IqueXdco_#_# (coded as above)
i.qu~n2*i.dco.. _IqueXdco_#_# (coded as above)
. d _I*,full
storage display value
variable name type format label variable label
-------------------------------------------------------------------------------------------------------------------------
_Iquestion2_0 byte %8.0g question2==0
_Iquestion2_1 byte %8.0g question2==1
_Iquestion2_2 byte %8.0g question2==2
_Idcount_da_0 byte %8.0g dcount_dacrime_cat==0
_Idcount_da_1 byte %8.0g dcount_dacrime_cat==1
_Idcount_da_2 byte %8.0g dcount_dacrime_cat==2
_Idcount_da_3 byte %8.0g dcount_dacrime_cat==3
_Idcount_da_4 byte %8.0g dcount_dacrime_cat==4
_IqueXdco_0_0 byte %8.0g question2==0 & dcount_dacrime_cat==0
_IqueXdco_0_1 byte %8.0g question2==0 & dcount_dacrime_cat==1
_IqueXdco_0_2 byte %8.0g question2==0 & dcount_dacrime_cat==2
_IqueXdco_0_3 byte %8.0g question2==0 & dcount_dacrime_cat==3
_IqueXdco_0_4 byte %8.0g question2==0 & dcount_dacrime_cat==4
_IqueXdco_1_0 byte %8.0g question2==1 & dcount_dacrime_cat==0
_IqueXdco_1_1 byte %8.0g question2==1 & dcount_dacrime_cat==1

Comment