Data visualization with SAS programming

PROC SGPLOT VBAR DATALABEL mean FORMAT issue

Reply
New Contributor
Posts: 3

PROC SGPLOT VBAR DATALABEL mean FORMAT issue

Hi, we are trying to use sgplot varbar ,

option:     vbar x / response =y   stat=mean datalabel ;

to put mean data above  each bar. however, we found we have no way to format datalabel.

Is there a way to format datalabel to avoid long tail of the mean?

We tried to format response Y. But it seems sgplot   gave a mean  based on formatted Y,   lacking original precision.

ie. after formating Y, MEAN=2.12,  but using the real numbers Mean=2.13,  how we solve this?

hard to pass QC.

ANY IDEA HOW TO SOLVE THIS?

Thank you!

SAS Super FREQ
Posts: 925

Re: PROC SGPLOT VBAR DATALABEL mean FORMAT issue

What version of SAS are you using?

New Contributor
Posts: 3

Re: PROC SGPLOT VBAR DATALABEL mean FORMAT issue

I am using SAS9.2  ON WIN7

Super Contributor
Posts: 252

Re: PROC SGPLOT VBAR DATALABEL mean FORMAT issue

Hi,

If you are using SAS 9.2 (or 9.3) you can use Graph Template Language with the plot statement barchart along with the option barlabelformat. If you need any more assistance please let me know.

Many thanks,

Kriss Harris

SAS Super FREQ
Posts: 925

Re: PROC SGPLOT VBAR DATALABEL mean FORMAT issue

Are you getting the 2.13 if you use PROC MEANS?

New Contributor
Posts: 3

Re: PROC SGPLOT VBAR DATALABEL mean FORMAT issue

Thank you all,

   Our QC people found the issue. they compare the values from tabulate against the graph from SGPLOT.

we used picture format .

   If use means, i figure it will be same thing.  may be i can get it done using GTL, but need to start afresh from syntax.

Is there easy ways to get it done.

PROC FORMAT;
   PICTURE TAB (ROUND) 
     1000000 - <10000000= "09999999" 
      100000 - <1000000 = "0999999" 
       10000 - <100000  = "099999" 
        1000 - <10000   = "09999" 
         100 - <1000    = "0999" 
          10 - <100     = "099.9" 
           1 - <10      = "09.99" 
          .1 - <1       = "9.999"
         .01 - <0.1     = "9.9999"
        .001 - <0.01    = "9.99999"
       .0001 - <0.001   = "9.999999"
      .00001 - <0.0001  = "9.9999999"
     .000001 - <0.00001 = "9.99999999"
    .0000001 - <0.000001= "9.999999999"

   -10000000 - <-1000000= "09999999"  (PREFIX="-")
    -1000000 - <-100000 = "0999999"  (PREFIX="-")
     -100000 - <-10000  = "099999"  (PREFIX="-")
      -10000 - <-1000   = "09999"  (PREFIX="-")
       -1000 - <-100    = "0999" (PREFIX="-")
        -100 - <-10     = "099.9"  (PREFIX="-")
         -10 - <-1      = "09.99"  (PREFIX="-")
          -1 - <-0.1      = "9.999"(PREFIX="-")
         -.1 - <-0.01     = "9.9999"(PREFIX="-")
        -.01 - <-0.001    = "9.99999"(PREFIX="-")
       -.001 - <-0.0001   = "9.999999"(PREFIX="-")
      -.0001 - <-0.00001  = "9.9999999"(PREFIX="-")
     -.00001 - <-0.000001 = "9.99999999"(PREFIX="-")
    -.000001 - <-0.0000001= "9.999999999"(PREFIX="-")
  ;

SAS Super FREQ
Posts: 1,141

Re: PROC SGPLOT VBAR DATALABEL mean FORMAT issue

proc template;
  define statgraph mean;
    begingraph;
      entrytitle 'Mean Mileage by Type';
      layout overlay;
         barchart x=type y=mpg_city / stat=mean
                       barlabel=true barlabelformat=4.1;
       endlayout;
     endgraph;
  end;
run;

ods listing;
ods graphics / reset width=5in height=3in imagename='mean';
proc sgrender data=sashelp.cars template=mean;
run;

mean.png

Ask a Question
Discussion stats
  • 6 replies
  • 2138 views
  • 0 likes
  • 4 in conversation