SHAZAM Community
Ask Your Question

Revision history [back]

You can use the GENR command to add any variables together. Below is a more detailed example using Dummy variables (see the manual). Remember when using them in a regression be careful of the Dummy Variable Trap.

* Generating 3 example types of dummy variables
* Note that the DUM(X) function variable is one when X > 0, 0 otherwise
genr d1=dum(3)  
genr d2=dum(time(0)-6) 
genr d3=dum(consume-income-1)

* Create a dummy as combination
genr d4 = d1+d2+d3

* Print the 4 variables
print d1-d4 / nobyvar

The output from this is:

 |_* Generating 3 example types of dummy variables
 |_* Note that the DUM(X) function variable is one when X > 0, 0 otherwise
 |_genr d1=dum(3)
 |_genr d2=dum(time(0)-6)
 |_genr d3=dum(consume-income-1)

 |_* Create a dummy as combination
 |_genr d4 = d1+d2+d3

 |_* Print the 4 variables
 |_print d1-d4 / nobyvar
       D1             D2             D3             D4
    1.000000      0.0000000E+00   1.000000       2.000000
    1.000000      0.0000000E+00  0.0000000E+00   1.000000
    1.000000      0.0000000E+00  0.0000000E+00   1.000000
    1.000000      0.0000000E+00   1.000000       2.000000
    1.000000      0.0000000E+00   1.000000       2.000000
    1.000000      0.0000000E+00   1.000000       2.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000
    1.000000       1.000000       1.000000       3.000000