Date: Thu, 4 Mar 2010 10:35:00 -0500
Reply-To: msz03@albany.edu
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Zdeb <msz03@ALBANY.EDU>
Subject: Re: Regarding Graph output
Content-Type: text/plain;charset=iso-8859-1
hi ... here's an idea (I think I interpreted your question correctly)
* test data, three observations per year;
data test;
input year change;
output;
change = change + ceil(10 * ranuni(123));
output;
change = change - ceil(10 * ranuni(123));
output;
datalines;
2000 -10
2001 10
2002 20
2003 -25
2004 6
;
run;
* new variable ... all positive values;
data test;
set test;
y = change + 30;
run;
*
new labels for the y-axis when using the new variable
lowest value is the value used in the above data step
;
proc format;
value y
0 = '-30'
10 = '-20'
20 = '-10'
30 = '0'
40 = '10'
50 = '20'
60 = '30'
;
run;
*
make an annotate data set to label chart when using new variable
cannot use "outside=mean" since the variable is rescaled and wrong values will appear
;
proc summary data=test nway;
var change;
class year;
output out=stats mean=;
run;
data anno;
retain xsys ysys '2' hsys '3' function 'label' size 2 position '2' style '"calibri"';
set stats (rename=(year=midpoint));
text = put(change,5.2);
run;
goptions reset=all ftext='calibri' htext=2 gunit=pct hpos=40;
axis1 label=(a=90 "ORIGINAL Y-AXIS");
axis2 order=0 to 60 by 10 label=(a=90 "MODIFIED Y-AXIS");
*
use the new variable, the format, and the annotate data set for the 2nd chart
all the bars go UP in the 2nd chart and are labeled with the mean for each year
;
proc gchart data=test;
vbar year / type=mean discrete sumvar=change raxis=axis1 outside=mean;
run;
vbar year / type=mean discrete sumvar=y raxis=axis2 href=30 annotate=anno;
format y y.;
run;
quit;
--
Mike Zdeb
U@Albany School of Public Health
One University Place
Rensselaer, New York 12144-3456
P/518-402-6479 F/630-604-1475
>Dear all,
>I am creating graphs of change from baseline of mean scores by visits. In
>my output I am getting some reverse bars as the mean change is negative. Is
>there any way to get all of them upward? I used order=(-25 to 50 by 5). But
>its not giving expected result. And also is there any way to get the mean
>change number on the top of the bar?[I used these statements:sumvar=chbl
>(change from baseline) type=mean outside=mean]. The bar width is 5(I put).
>Still I am not getting the expected results. Would you please help me in
>this regard.
>Thank you.