You can try using xi
, both as a stand-alone command to create indicator and interaction terms, and as a command prefix. A nonsensical example:
clear all
set more off
sysuse auto
* stand-alone
xi i.rep78*mpg
* as prefix
xi: regress price i.rep78*mpg
Run help xi
for all the details.
Edit
To make this a bit clearer, suppose the regress
command did not admit the use of either factor variable notation or the xi:
prefix. Then using the xi
stand-alone syntax you could create the indicator and interaction terms (which answers your original question) and then use those terms with the regress
command:
sysuse auto, clear
xi i.rep78*mpg
regress price mpg _Irep78* _IrepXmpg*
(Remember to use Stata's help capabilities. Running search interactions
, for example, leads you to xi......Interaction expansion.)