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 (January 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 26 Jan 2006 01:04:26 +0000
Reply-To:   toby dunn <tobydunn@HOTMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   toby dunn <tobydunn@HOTMAIL.COM>
Subject:   Re: Weird results trying to classify variable
Comments:   To: jo_kln@YAHOO.CO.UK
In-Reply-To:   <dr8ou7$6to$1@news.ox.ac.uk>
Content-Type:   text/plain; format=flowed

Jo ,

All I have at home is Le v8.2 but this should do:

data test ; infile cards ; input postcode $5. ; cards ; 10294 68395 60382 50186 20385 ; run ;

data classified ; length NumPostCode 8 Classify $1 ; set test ; numpostcode = postcode ;

if ( 53999 >= numpostcode >= 50000 ) or ( 42999 >= numpostcode >= 40000 ) then classify = '1' ; else if ( 16999 >= numpostcode >= 13000 ) then classify = '2' ; else classify = '3' ; run ;

proc Format; value $class '1' = 'Region one ' '2' = 'Region two ' '3' = 'No region assigned' ; run ;

proc gchart data = classified ; format classify $class. ; pie3d classify ; run ; quit ;

Toby Dunn

From: Jo Klein <jo_kln@YAHOO.CO.UK> Reply-To: Jo Klein <jo_kln@YAHOO.CO.UK> To: SAS-L@LISTSERV.UGA.EDU Subject: Weird results trying to classify variable Date: Wed, 25 Jan 2006 21:00:55 +0000

Dear SAS wizards, I'm analyzing a data set that includes postcode information. I'd like to create a pie chart of customers near our facilities. Postcodes are stored in character variables, I convert them to numeric for easier handling, then I use proc gchart to get my pie. When I run the code, I get an unexpected result. The pie portion depicting "No region assigned" looks fine, but the format code for the other two regions fails. SAS plots values of 1.2 and 1.8 instead of the expected 1 and 2 (which would have been substituted through the format code). I'm running SAS 9.1 on Windows, and I've attached a code snippet to illustrate my problem. I'd be really grateful if one of you experts could some shed light on this baffling behaviour. Another question regarding pie3d, funnily, it doesn't seem to take the percent keyword like hbar3d? Is there a way to make pie3d plot percentages instead of frequencies? Thanks everyone, Jo

data test; infile cards; input postcode $5.; cards; 10294 68395 60382 50186 20385 ;;; data classified; set test; attrib numpostcode length=8; attrib classify length=8; numpostcode=postcode; classify=3; if 53999>=numpostcode>=50000 then classify=1; else if 42999>=numpostcode>=40000 then classify=1; else if 16999>=numpostcode>=13000 then classify=2; run; proc Format; value classfmt 1='Region one' 2='Region two' 3='No region assigned' ; proc gchart data=classified; format classify classfmt.; pie3d classify ; run;


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