10/18/2007

Creating and Using Dummy Variables

A dummy variable is a numerical variable used in regression analysis to represent subgroups of the sample in your study. Dummy variable is used to distinguish different treatment groups. They are useful because they enable us to use a single regression equation to represent multiple groups. This means we don't need to write out separate equation models for each subgroup. If we have "n" subgroups we will have (n-1) dummy variables.
EX:
consider this simple data file having 9 subjects in 3 groups with a score iv dv.

sas program :

data dummy;
input sub iv dv;
cards;
1 1 48
2 1 49
3 1 50
4 2 17
5 2 20
6 2 23
7 3 28
8 3 30
9 3 32
;
run;
data dummy2;
set dummy;
if (iv=1) then iv1=1; else iv1=0;
if (iv=2) then iv2=1; else iv2=0;
if (iv=3) then iv3=1; else iv3=0;
run;
proc reg data=dummy2;
model dv=iv1 iv2;
run;

2 comments:

Onur said...

bence guzel olmus yararlı bilgiler var

emreb-n said...

thank you bro!!!