|
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;
|