Date: Thu, 7 Dec 2006 10:44:39 -0500
Reply-To: Lei <kiki886@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Lei <kiki886@GMAIL.COM>
Subject: How to change a categorical variable into a set of indicator
variables?
Suppose I have a following dataset
Id a1
1 2
2 5
3 4
4 1
I want a1 to be expressed in a set of indicator variables. The number of
indicator vars is determined by the max of a1. The result dataset needs to
be like
id b1 b2 b3 b4 b5
1 0 1 0 0 0
2 0 0 0 0 1
3 0 0 0 1 0
4 1 0 0 0 0
Any input? TIA.
|