All I have at home is Le v8.2 but this should do:
data test ;
infile cards ;
input postcode $5. ;
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' ;
'1' = 'Region one '
'2' = 'Region two '
'3' = 'No region assigned'
data = classified ;
format classify $class. ;
pie3d classify ;
From: Jo Klein <jo_kln@YAHOO.CO.UK>
Reply-To: Jo Klein <jo_kln@YAHOO.CO.UK>
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
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?
input postcode $5.;
attrib numpostcode length=8;
attrib classify length=8;
if 53999>=numpostcode>=50000 then classify=1;
if 42999>=numpostcode>=40000 then classify=1;
if 16999>=numpostcode>=13000 then classify=2;
value classfmt 1='Region one'
3='No region assigned'
proc gchart data=classified;
format classify classfmt.;
pie3d classify ;