SAS/Graph - bar chart and axis statement

SAS/Graph - bar chart and axis statement

Post by Fondurulia, Jul » Fri, 20 Sep 2002 03:15:37



Greetings,

I am struggling with trying to print three to four lines of information
under the x-axis of a bar chart.  I have the sample data and program below
which seems to generate the bar chart correctly.  Despite trying several
combinations of axes statements and single axis stament with different
options, I have not been able to print the desired information.

Ideally the x-axis would have the service category in the first line, a
second line for service categories with long labels, such as inaptient
acute, a third line with the actual site and plan PMPM cost, or a third and
a fourth line with the site and plan PMPM cost.  Is this possible?   From
the documentation and sample programs I have found on the SAS website, it
seemed like justify= option would let me do something like this, though I
was not sure whether I would be able to put the actual values even if I
converted them to macro variables.  Since I have not been able to get the
first line or a second line to print well, I have not attempted getting the
actual values to display, yet.

Any suggestions or comments would be appreciated!  Also, if there are easier
ways to create the chart itself, I would be very interested.
--Julie Fondurulia

data test4;
  input servcat $ 1-20 sitepmpm planpmpm;
  cards;
inpatient acute     25.33 28.02
inpatient chronic    0.35  0.37
outpatient                   0.56  0.79
ER                       4.22  4.05
physician specialty 30.34 26.33
primary care            14.98 20.24
HH & therapies       4.92  6.35
BH inpatient         5.65  5.78
BH outpatient       15.83 16.43
pharmacy            27.11 22.80
other               36.62 39.18
;
run;

data test1;
  set test4;
  status='plan';
  drop sitepmpm;
run;

data test2;
  set test4;
  status='site';
  drop planpmpm;
run;

data test6;
  set test1 test2(rename=(sitepmpm=planpmpm));
  p+1;
run;

proc sort data=test6;
  by servcat descending status;
run;

data test6;
  retain n 0;
  set test6;
  n=n+1;
run;

goptions reset=all border rotate=landscape;

data anno;
  length function color $8.;
  retain function 'bar' xsys '2' style 'solid' ct 0;
  set test6;
  ct=ct+1;
  function='move'; x=ct; xsys='2'; ysys='2'; y=0; output;
  function='move'; x=-3; xsys='9'; y=0; output;
  if status='site' then color='pink';
  if status='plan' then color='purple';
  function='bar'; xsys='9'; x=+2; ysys='2'; y=planpmpm; output;
  if n in(2,4,6,8,10,12,14,16,18,20,22,24) then do;
    ct=ct+1;
    function='move'; x=+.25; xsys='2'; ysys='2'; y=0; output;
  end;
run;

proc print data=anno;
run;

symbol i=none v=none;

axis1 order=(0 to 32 by 2)
      value=(font=zapfu height=0.7
             tick=1 justify=c 'BH' justify=c '1' justify=c '2'
               tick=2 justify=c 'Inp'
                         tick=4 justify=c 'BH' justify=c '3' justify=c '4'
                         tick=5 justify=c 'Outp'
                         tick=7 justify=c 'ER' justify=c '5' justify=c '6'
                 tick=10 justify=c 'HH and' justify=c '7' justify=c '8'
                         tick=11 justify=c 'therapies'
                         tick=13 justify=c 'Inp' justify=c '9' justify=c
'10'
                         tick=14 justify=c 'Acute'
                         tick=16 justify=c 'Inp' justify=c '11' justify=c
'12'
                         tick=17 justify=c 'Chronic'
                         tick=19 justify=c 'Other' justify=c '13' justify=c
'14'
                         tick=22 justify=c 'Outpatient' justify=c '15'
justify=c '16'
                         tick=25 justify=c 'Pharmacy' justify=c '17'
justify=c '18'
             tick=28 justify=c 'Spec' justify=c '19' justify=c '20'
                         tick=31 justify=c 'PC' justify=c '19' justify=c
'20')
            major=(number=10) label=none minor=none ;

axis10 order=(0 to 32 by 2)
      value=(font=zapfu height=0.5 angle=0 rotate=0
             '     BH Inp' ' '
             'BH Outp'
             '     ER'  ' '
             'HH and'
             '      Inpati-' ' '
             ' Inpati-'
             '      Other' ' '
             ' Outpati-'
             '       Pharmacy' ' '
             'Spec' ' '
             'Primary'
             justify=l
             '  '
             '  '
             '  '
             'therapy'
             '  '
             'ent Acute'
             'ent Chronic'
             '  '
             'ent'
             '  '
             'ialty'
             'Care')
            major=none label=none minor=none ;

axis6 label=none order=(0 to 40 by 10) offset=(0);

title1 f=zapfu c=black h=.7 'Actual Expenses by Clinical Service Category';
legend1 down=2 position=(bottom outside center) across=12
        value=(tick=1 'Site' tick=2 'Plan') mode=share;

proc gplot data=test6;
  plot planpmpm*n / anno=anno haxis=axis10
                    vaxis=axis6
                    legend=legend1 frame ;
run;
quit;

 
 
 

SAS/Graph - bar chart and axis statement

Post by Huang, » Fri, 20 Sep 2002 06:39:14


Julie,

You can try 'split' option in axis statement:

data xx;
do x=1 to 3;
y=ranuni(0);
output;
end;

proc format;
value xfmt
1='Line1,line2,line3'
2='DEF,GHI'
3='KJIA,ASDAS'
;

axis1 split=',';

proc gplot;
plot y*x / haxis=axis1;
title;
format x xfmt.;
run;
quit;

Kind regards,

Ya Huang

-----Original Message-----

Sent: Wednesday, September 18, 2002 11:16 AM

Subject: SAS/Graph - bar chart and axis statement

Greetings,

I am struggling with trying to print three to four lines of information
under the x-axis of a bar chart.  I have the sample data and program below
which seems to generate the bar chart correctly.  Despite trying several
combinations of axes statements and single axis stament with different
options, I have not been able to print the desired information.

Ideally the x-axis would have the service category in the first line, a
second line for service categories with long labels, such as inaptient
acute, a third line with the actual site and plan PMPM cost, or a third and
a fourth line with the site and plan PMPM cost.  Is this possible?   From
the documentation and sample programs I have found on the SAS website, it
seemed like justify= option would let me do something like this, though I
was not sure whether I would be able to put the actual values even if I
converted them to macro variables.  Since I have not been able to get the
first line or a second line to print well, I have not attempted getting the
actual values to display, yet.

Any suggestions or comments would be appreciated!  Also, if there are easier
ways to create the chart itself, I would be very interested.
--Julie Fondurulia

data test4;
  input servcat $ 1-20 sitepmpm planpmpm;
  cards;
inpatient acute     25.33 28.02
inpatient chronic    0.35  0.37
outpatient                   0.56  0.79
ER                       4.22  4.05
physician specialty 30.34 26.33
primary care            14.98 20.24
HH & therapies       4.92  6.35
BH inpatient         5.65  5.78
BH outpatient       15.83 16.43
pharmacy            27.11 22.80
other               36.62 39.18
;
run;

data test1;
  set test4;
  status='plan';
  drop sitepmpm;
run;

data test2;
  set test4;
  status='site';
  drop planpmpm;
run;

data test6;
  set test1 test2(rename=(sitepmpm=planpmpm));
  p+1;
run;

proc sort data=test6;
  by servcat descending status;
run;

data test6;
  retain n 0;
  set test6;
  n=n+1;
run;

goptions reset=all border rotate=landscape;

data anno;
  length function color $8.;
  retain function 'bar' xsys '2' style 'solid' ct 0;
  set test6;
  ct=ct+1;
  function='move'; x=ct; xsys='2'; ysys='2'; y=0; output;
  function='move'; x=-3; xsys='9'; y=0; output;
  if status='site' then color='pink';
  if status='plan' then color='purple';
  function='bar'; xsys='9'; x=+2; ysys='2'; y=planpmpm; output;
  if n in(2,4,6,8,10,12,14,16,18,20,22,24) then do;
    ct=ct+1;
    function='move'; x=+.25; xsys='2'; ysys='2'; y=0; output;
  end;
run;

proc print data=anno;
run;

symbol i=none v=none;

axis1 order=(0 to 32 by 2)

      value=(font=zapfu height=0.7
             tick=1 justify=c 'BH' justify=c '1' justify=c '2'
               tick=2 justify=c 'Inp'
                         tick=4 justify=c 'BH' justify=c '3' justify=c '4'
                         tick=5 justify=c 'Outp'
                         tick=7 justify=c 'ER' justify=c '5' justify=c '6'
                 tick=10 justify=c 'HH and' justify=c '7' justify=c '8'
                         tick=11 justify=c 'therapies'
                         tick=13 justify=c 'Inp' justify=c '9' justify=c
'10'
                         tick=14 justify=c 'Acute'
                         tick=16 justify=c 'Inp' justify=c '11' justify=c
'12'
                         tick=17 justify=c 'Chronic'
                         tick=19 justify=c 'Other' justify=c '13' justify=c
'14'
                         tick=22 justify=c 'Outpatient' justify=c '15'
justify=c '16'
                         tick=25 justify=c 'Pharmacy' justify=c '17'
justify=c '18'
             tick=28 justify=c 'Spec' justify=c '19' justify=c '20'
                         tick=31 justify=c 'PC' justify=c '19' justify=c
'20')
            major=(number=10) label=none minor=none ;

axis10 order=(0 to 32 by 2)
      value=(font=zapfu height=0.5 angle=0 rotate=0
             '     BH Inp' ' '
             'BH Outp'
             '     ER'  ' '
             'HH and'
             '      Inpati-' ' '
             ' Inpati-'
             '      Other' ' '
             ' Outpati-'
             '       Pharmacy' ' '
             'Spec' ' '
             'Primary'
             justify=l
             '  '
             '  '
             '  '
             'therapy'
             '  '
             'ent Acute'
             'ent Chronic'
             '  '
             'ent'
             '  '
             'ialty'
             'Care')
            major=none label=none minor=none ;

axis6 label=none order=(0 to 40 by 10) offset=(0);

title1 f=zapfu c=black h=.7 'Actual Expenses by Clinical Service Category';
legend1 down=2 position=(bottom outside center) across=12
        value=(tick=1 'Site' tick=2 'Plan') mode=share;

proc gplot data=test6;
  plot planpmpm*n / anno=anno haxis=axis10
                    vaxis=axis6
                    legend=legend1 frame ;
run;
quit;


 
 
 

SAS/Graph - bar chart and axis statement

Post by Julie A. Fondurul » Fri, 20 Sep 2002 10:48:38


Ya,

Thank you so very much for your help!  This works wonderfully!

--Julie


> Julie,

> You can try 'split' option in axis statement:

> data xx;
> do x=1 to 3;
> y=ranuni(0);
> output;
> end;

> proc format;
> value xfmt
> 1='Line1,line2,line3'
> 2='DEF,GHI'
> 3='KJIA,ASDAS'
> ;

> axis1 split=',';

> proc gplot;
> plot y*x / haxis=axis1;
> title;
> format x xfmt.;
> run;
> quit;

> Kind regards,

> Ya Huang

> -----Original Message-----

> Sent: Wednesday, September 18, 2002 11:16 AM

> Subject: SAS/Graph - bar chart and axis statement

> Greetings,

> I am struggling with trying to print three to four lines of information
> under the x-axis of a bar chart.  I have the sample data and program below
> which seems to generate the bar chart correctly.  Despite trying several
> combinations of axes statements and single axis stament with different
> options, I have not been able to print the desired information.

> Ideally the x-axis would have the service category in the first line, a
> second line for service categories with long labels, such as inaptient
> acute, a third line with the actual site and plan PMPM cost, or a third and
> a fourth line with the site and plan PMPM cost.  Is this possible?   From
> the documentation and sample programs I have found on the SAS website, it
> seemed like justify= option would let me do something like this, though I
> was not sure whether I would be able to put the actual values even if I
> converted them to macro variables.  Since I have not been able to get the
> first line or a second line to print well, I have not attempted getting the
> actual values to display, yet.

> Any suggestions or comments would be appreciated!  Also, if there are easier
> ways to create the chart itself, I would be very interested.
> --Julie Fondurulia

> data test4;
>   input servcat $ 1-20 sitepmpm planpmpm;
>   cards;
> inpatient acute     25.33 28.02
> inpatient chronic    0.35  0.37
> outpatient                   0.56  0.79
> ER                       4.22  4.05
> physician specialty 30.34 26.33
> primary care            14.98 20.24
> HH & therapies       4.92  6.35
> BH inpatient         5.65  5.78
> BH outpatient       15.83 16.43
> pharmacy            27.11 22.80
> other               36.62 39.18
> ;
> run;

> data test1;
>   set test4;
>   status='plan';
>   drop sitepmpm;
> run;

> data test2;
>   set test4;
>   status='site';
>   drop planpmpm;
> run;

> data test6;
>   set test1 test2(rename=(sitepmpm=planpmpm));
>   p+1;
> run;

> proc sort data=test6;
>   by servcat descending status;
> run;

> data test6;
>   retain n 0;
>   set test6;
>   n=n+1;
> run;

> goptions reset=all border rotate=landscape;

> data anno;
>   length function color $8.;
>   retain function 'bar' xsys '2' style 'solid' ct 0;
>   set test6;
>   ct=ct+1;
>   function='move'; x=ct; xsys='2'; ysys='2'; y=0; output;
>   function='move'; x=-3; xsys='9'; y=0; output;
>   if status='site' then color='pink';
>   if status='plan' then color='purple';
>   function='bar'; xsys='9'; x=+2; ysys='2'; y=planpmpm; output;
>   if n in(2,4,6,8,10,12,14,16,18,20,22,24) then do;
>     ct=ct+1;
>     function='move'; x=+.25; xsys='2'; ysys='2'; y=0; output;
>   end;
> run;

> proc print data=anno;
> run;

> symbol i=none v=none;

> axis1 order=(0 to 32 by 2)

>       value=(font=zapfu height=0.7
>              tick=1 justify=c 'BH' justify=c '1' justify=c '2'
>                tick=2 justify=c 'Inp'
>                          tick=4 justify=c 'BH' justify=c '3' justify=c '4'
>                          tick=5 justify=c 'Outp'
>                          tick=7 justify=c 'ER' justify=c '5' justify=c '6'
>                  tick=10 justify=c 'HH and' justify=c '7' justify=c '8'
>                          tick=11 justify=c 'therapies'
>                          tick=13 justify=c 'Inp' justify=c '9' justify=c
> '10'
>                          tick=14 justify=c 'Acute'
>                          tick=16 justify=c 'Inp' justify=c '11' justify=c
> '12'
>                          tick=17 justify=c 'Chronic'
>                          tick=19 justify=c 'Other' justify=c '13' justify=c
> '14'
>                          tick=22 justify=c 'Outpatient' justify=c '15'
> justify=c '16'
>                          tick=25 justify=c 'Pharmacy' justify=c '17'
> justify=c '18'
>              tick=28 justify=c 'Spec' justify=c '19' justify=c '20'
>                          tick=31 justify=c 'PC' justify=c '19' justify=c
> '20')
>             major=(number=10) label=none minor=none ;

> axis10 order=(0 to 32 by 2)
>       value=(font=zapfu height=0.5 angle=0 rotate=0
>              '     BH Inp' ' '
>              'BH Outp'
>              '     ER'  ' '
>              'HH and'
>              '      Inpati-' ' '
>              ' Inpati-'
>              '      Other' ' '
>              ' Outpati-'
>              '       Pharmacy' ' '
>              'Spec' ' '
>              'Primary'
>              justify=l
>              '  '
>              '  '
>              '  '
>              'therapy'
>              '  '
>              'ent Acute'
>              'ent Chronic'
>              '  '
>              'ent'
>              '  '
>              'ialty'
>              'Care')
>             major=none label=none minor=none ;

> axis6 label=none order=(0 to 40 by 10) offset=(0);

> title1 f=zapfu c=black h=.7 'Actual Expenses by Clinical Service Category';
> legend1 down=2 position=(bottom outside center) across=12
>         value=(tick=1 'Site' tick=2 'Plan') mode=share;

> proc gplot data=test6;
>   plot planpmpm*n / anno=anno haxis=axis10
>                     vaxis=axis6
>                     legend=legend1 frame ;
> run;
> quit;

 
 
 

1. SAS GRAPH AXIS statement

Hi,

How can I set my AXIS statement to automatically put a
minor tick for each month of data.  Essentially, this
would mean setting the minor axis to put a tick for
each equally spaced horizontal data point regardless
of its real world meaning.

axis2 color=black LABEL=NONE OFFSET=(0.3,0.3) cm
VALUE=(HEIGHT=0.40 CM)   minor=NONE;

Right now, I am suppressing the minor axis.

I had tried writing a statement like this:

* major=(number=&NUMBERMonths HEIGHT=.25 cm) ;

using a macro variable, but it did not work.

Any thoughts?

I think SAS should have a default option to work with
equally spaced data.

Stephen

__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com

2. Midi

3. Bold text (one bar only) on axis in horizontal bar chart - help required

4. CodeWarrior 10 Early Order Special

5. SAS Tracking Number us5663927 (Making a bar chart in SAS)

6. Scp Error?

7. How to properly combine a graph and a bar chart?

8. Detailed transactions into Summary tables

9. Question about warning message from SAS/GRAPH (uneven axes)

10. Two SAS/Graph AXIS questions

11. Newbie Problem: SAS Graph Axis/Title/Legend GIF problem

12. SAS Graph - formatted axis values are truncated

13. SAS graph with 2 vertical axes