|
Hi Craig,
what do you think about the following:
data temp;
set freqout;
length datec $8;
m=month(date);
yearc=put(year(date),4.);
select (m);
when (1) datec="JAN "!!yearc;
when (2) datec="FEB "!!yearc;
when (3) datec="MAR "!!yearc;
when (4) datec="APR "!!yearc;
when (5) datec="MAY "!!yearc;
when (6) datec="JUN "!!yearc;
when (7) datec="JUL "!!yearc;
when (8) datec="AUG "!!yearc;
when (9) datec="SEP "!!yearc;
when (10) datec="OCT "!!yearc;
when (11) datec="NOV "!!yearc;
when (12) datec="DEC "!!yearc;
end;
run;
proc sort nodupkey force;
by m y;
run;
data _null_;
set temp;
call symput("d"!!compress(put(_n_,8.)),datec);
run;
axis2 label = (h=1.7 'Date') value=(
tick=1 "&D1" justify=c ' '
tick=2 ' ' justify=c "&d2"
tick=3 "&d3" justify=c ' '
tick=4 ' ' justify=c "&d4"
tick=5 "&d5" justify=c ' '
tick=6 ' ' justify=c "&d6"
tick=7 "&d7" justify=c ' '
tick=8 ' ' justify=c "&d8"
tick=9 "&d9" justify=c ' '
tick=10 ' ' justify=c "&d10");
proc gchart data=freqout;
vbar date/discrete sumvar=frequency maxis=axis2 raxis=axis1 outside=sum
;
run; quit;
That depends on the 10 months in your frequency dataset. If you have more,
force it to 10 by subsetting. If you wnat to make that dynamic, it would be
a thing of a macro mit much more coding. But if the 10 are and rest ok, then
that should do it.
On Fri, 27 Oct 2006 20:34:06 +1000, Craig Hansen <C.Hansen@UQ.EDU.AU> wrote:
>Dear All
>
>I have data for admissions to a clinic and based on a date variable I am
>wanting to plot how many patients entered the clinic for each month over
>a period of time that covers Nov 2005 to Aug 2006. I have used the
>program below, which is fine, however because the major ticks on the
>maxis are dates (eg. NOV05, DEC05...AUG06 etc) the font size has to be
>small for them to fit along the maxis. To overcome this I used tick=1
>'NOV' justify=c '2005.....tick=10 'AUG' justify=c '2006', but I am
>wondering if there is an option where the dates on the maxis can be put
>on two lines (similar to the DOWN=2 option in a legend statement). I
>will run this plot every month as new admissions are added to the data
>so I don't want to have to type in the tick/justify options everytime
>for the new months.
>
>Here is the program I used:
>
>proc sort data=a;
>by year month;
>ods output OneWayFreqs=freqout;
>proc freq data=a;
>by year month;
>table count;
>run;
>ods output close;
>data freqout; set freqout;
>dummy=1;
>date=mdy(month,dummy,year);
>format date monyy5.;
>run;
>goptions reset=all htext=1.2 ftext=swissb;
>axis1 label = (angle=90 c=black h=1.7 'Frequency');
>axis2 label = (h=1.7 'Date') value=(tick=1 'NOV' justify=c '2005'
> tick=2 'DEC'
>justify=c '2005'
> tick=3 'JAN'
>justify=c '2006'
> tick=4 'FEB'
>justify=c '2006'
> tick=5 'MAR'
>justify=c '2006'
> tick=6
>'APR' justify=c '2006'
> tick=7
>'MAY' justify=c '2006'
> tick=8
>'JUN' justify=c '2006'
> tick=9
>'JUL' justify=c '2006'
> tick=10
>'AUG' justify=c '2006');
>proc gchart data=freqout;
>vbar date/discrete sumvar=frequency maxis=axis2 raxis=axis1 outside=sum
>;
>run; quit;
>
>
>The other option was to use 'vbar month/discrete sumvar=frequency
>GROUP=year' but it shows other months in 2005 and 2006 where there are
>no entries. I want it to start at NOV2005 and finish AUG2006.
>
>
>
>Thanks in advance for any help
>Craig
|