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 (July 2009, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 30 Jul 2009 14:55:04 -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: UPDATE: Character/numeric issue when using ARRAY function...
Comments: To: Pete <phlarsen@yahoo.com>
In-Reply-To:  <200907301945.n6UH5KW3001255@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1

data example; input project_ID Measure_Name $; cards; 1111 boiler 1111 chiller 2222 lighting 2222 heating 3333 heating 4444 power 5555 furnace 5555 lamp 6666 exit signs 6666 lamp 6666 ballast ; run; proc summary data=example completetypes nway; class project_id measure_name; output out=expanded(drop=_type_); run; ***Transpose data; proc transpose data=work.expanded out=work.measures_trans (drop=_NAME_); by Project_ID ; id Measure_Name; var _freq_; run; proc print; run;

On 7/30/09, Pete <phlarsen@yahoo.com> wrote: > In short, how do I write this code so that the variables' names are based on > the text values originally in work.example, but the values under each > variable are "0" or "1" in numeric format (i.e., binomial coding)? Thanks. > > Here is some more information, including a simplified data example. I am > using an ARRAY, because there are over a hundred unique text values in my > real data (not simply nine variables as noted in this simplified dataset). > > data example; > input project_ID Measure_Name $; > cards; > 1111 boiler > 1111 chiller > 2222 lighting > 2222 heating > 3333 heating > 4444 power > 5555 furnace > 5555 lamp > 6666 exit signs > 6666 lamp > 6666 ballast > ; > run; > > ***Transpose data; > proc transpose data=work.example out=work.measures_trans (drop=_NAME_); > by Project_ID ; > id Measure_Name; > var Measure_Name; > run; > > ***Fix to format error but drops variable name; > ***How do I write this code so that the variables names are based on the > text values originally in work.example, but the values under each variable > are "0" or "1" in numeric format?; > > data measures_trans (keep=Project_ID wan:); > set measures_trans; > array measure (*) boiler -- ballast; > array want (9); > do i = 1 to dim(measure); > if missing(measure(i)) then want(i)=0; > else want(i)=1; > end; > run; >


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