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 (August 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 5 Aug 2009 11:14:42 -0500
Reply-To:     "Data _null_;" <iebupdte@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Data _null_;" <iebupdte@GMAIL.COM>
Subject:      Re: Adding class/dummy variable
Comments: To: Billy Rubin <billy_rubin1618@yahoo.com>
In-Reply-To:  <862981.85730.qm@web44703.mail.sp1.yahoo.com>
Content-Type: text/plain; charset=ISO-8859-1

proc summary nway; class x; output out=levels(drop=_freq_ _type_ index=(x)) / levels; run; data a; set a; set levels key=x/unique; run;

Or make and INFORMAT etc.

On 8/5/09, Billy Rubin <billy_rubin1618@yahoo.com> wrote: > My brain is failing me...I know I've done this many times, but I cannot access the knowledge this morning. > > How does one create a classification/dummy variable without going through so many data/sql steps. I have a data table with many string classes and I want to add a numerical classification variable. What is the trick? > > > > data a (drop=i); > length x $ 2 ; > do i = 1 to 50; > X = byte(96 + ceil(ranuni(1)*5) ) ; > output; > end; > run; > > proc sql; > create table b as > select distinct x > from a > order by x; > quit; > > data c; set b; > CLASS = _n_; > run; > > proc sql; > create table d as > select a.*, c.* > from a, c > where a.x = c.x > order by x ; > quit; >


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