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 08:47:32 -0700
Reply-To:   Billy Rubin <billy_rubin1618@YAHOO.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Billy Rubin <billy_rubin1618@YAHOO.COM>
Subject:   Adding class/dummy variable
Content-Type:   text/plain; charset=us-ascii

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