LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2000, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 27 Jun 2000 11:32:25 -0400
Reply-To:     Paige Miller <paige.miller@KODAK.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Paige Miller <paige.miller@KODAK.COM>
Organization: Eastman Kodak Company
Subject:      Re: Creating dummy vars (lots of them)
Content-Type: text/plain; charset=us-ascii

David Richmond wrote: > > Hi, > I'm trying to create a very large set of dummy variables from a > single grouping variable which takes on nearly 1000 unique values. Each > dummy corresponds to a unique value of the grouping variable. The dummy > needs to equal 1 when the group var equals the corresponding value for the > dummy var and 0 otherwise. The example below illustrates what I mean. > > id dum1 dum2 dum3 > 1 1 0 0 > 2 0 1 0 > 2 0 1 0 > 3 0 0 1 > 3 0 0 1 > > I have two questions: > 1) is there an easy way to do this? > I've thought about trying to do this with macros, but my problem is that > I want SAS to figure out how many dummies it needs using the 'max' option in > proc univariate (i.e. what's the largest value of "id"?) and then pass that > number to a macro so it can execute a loop to create the dummies one by one. > I have no idea how to do this. > > 2) I'm essentially trying to do a fixed effects model (w/ logistic reg.), > is there a better way to do this in SAS?

All of the responses so far use some DATA step or macro manipulations to do this. All of this DATA step or macro programming is unnecessary. A much easier way is PROC GLMMOD, which I believe was experimental in SAS 6 but is production in SAS 8.

-- Paige Miller Eastman Kodak Company paige.miller@kodak.com

"It's nothing until I call it!" -- Bill Klem, NL Umpire "Those black-eyed peas tasted all right to me" -- Dixie Chicks


Back to: Top of message | Previous page | Main SAS-L page