Data visualization with SAS programming

PROC GCHART graphic area problem

Accepted Solution Solved
Reply
Super Contributor
Posts: 543
Accepted Solution

PROC GCHART graphic area problem

Hi.

I have a working code that manifests differently for what seems to me very similar conditions. PLease see below:

I have a data set that has estimates from a couple of models (one assessing within the other one between subjects...)

I  initially had a chart that plotted the estimates from both models in one plot:

data have;

    input measure $ 1-19 model $ Estimate ;

cards;

First, Measure     b_gfr         3.48

First, Measure     d_gfr_10      3.56

Second, Measure    b_gfr         1.38

Second, Measure    d_gfr_10      2.22

Third, Measure     b_gfr         1.40

Third, Measure     d_gfr_10      2.03

Fourth, Measure    b_gfr         1.38

Fourth, Measure    d_gfr_10      3.28

Fifth, Measure     b_gfr         0.85

Fifth, Measure     d_gfr_10      1.51

Sixth, Measure     b_gfr         0.07

Sixth, Measure     d_gfr_10      0.38

Seventh, Measure   b_gfr         0.63

Seventh, Measure   d_gfr_10      0.93

Eighth, Measure    b_gfr         2.99

Eighth, Measure    d_gfr_10      5.17

;

filename models "&plot_path.\models_both.jpeg";

goptions reset = all device = jpeg gsfname = models gsfmode = replace ;

options orientation=landscape  nodate nonumber ;

pattern1 color = graycc;

pattern2 color = gray;

    axis1 label = none minor = none order = (0.0 to 7.0 by 1) value = none major = none c = white;

    axis2 label = none  value = none;

    axis3 split = "," label = none value = (f = "Arial/Bold" h = 1.2 ) c = black;

legend label = none position = (inside top left) mode = protect across = 1

                value = (h = 1.7 f = "Arial" "Between-Patient Models" "Within-Patient Models");

proc gchart data = have ;

    vbar model/

        sumvar = estimate NoZero space = 0

        group = measure subgroup = model legend = legend

        type = mean iframe = black

        raxis = axis1  maxis = axis2 gaxis = axis3

        coutline = black

     ;

run;quit;

It turns out the request is now for separate plots. Very easy to do, I just split the code and restrict the data to one mode at the time, using a where statement.

filename models "&plot_path.\models_cross.jpeg";

goptions device = jpeg gsfname = models gsfmode = replace ;

options orientation=landscape  nodate nonumber ;

    axis1 label = none minor = none order = (0 to 7 by 1)

    value = none major = none c = white;

    axis2 label = none  value = none;

    axis3 split = "," label = none value = (f = "Arial/Bold" h = 1.2 ) c = black;

pattern color = grayee;

legend label = none position = (inside top left) mode = protect across = 1

                value = (h = 1.7 f = "Arial" "Between-Patient Models");

proc gchart data = have ;where model = 'b_gfr';

    vbar model/

        sumvar = estimate NoZero space = 0

        group = measure legend = legend

        type = mean iframe = black

        raxis = axis1  maxis = axis2 gaxis = axis3

        coutline = black

     ;

run;quit;

filename models "&plot_path.\models_within.jpeg";

goptions device = jpeg gsfname = models gsfmode = replace ;

options orientation=landscape  nodate nonumber ;

    axis1 label = none minor = none order = (0 to 7 by 1)

    value = none major = none c = white;

    axis2 label = none  value = none;

    axis3 split = "," label = none value = (f = "Arial/Bold" h = 1.2 ) c = black;

pattern color = gray;

legend label = none position = (inside top left) mode = protect across = 1

                value = (h = 1.7 f = "Arial" "Within-Patient Models");

proc gchart data = have ;where model = 'd_gfr_10';

    vbar model/

        sumvar = estimate NoZero space = 0

        group = measure legend = legend

        type = mean iframe = black

        raxis = axis1  maxis = axis2 gaxis = axis3

        coutline = black

     ;

run;quit;

OK, so my problem is that one plot 'fills' the graphic area, the other one seems to be smaller and I can't figure out why.



Any help would be highly appreciated.


Thank you!


Anca.



Accepted Solutions
Solution
‎02-12-2013 11:41 AM
SAS Employee
Posts: 980

Re: PROC GCHART graphic area problem

Your code seems a bit overly-tricky, using the group= option for what is visually not a grouped bar chart.

I would use the following simplified code instead:

axis1 label=none minor=none order=(0 to 7 by 1) value=none major=none c=white;

axis2 split="," label=none;

pattern color=grayee;

proc gchart data=have; where model='b_gfr';

    vbar measure /

        sumvar=estimate NoZero

        legend=legend

        type=mean iframe=black

        raxis=axis1 maxis=axis2

        coutline=black;

run;

pattern color=gray;

proc gchart data=have; where model = 'd_gfr_10';

    vbar measure /

        sumvar=estimate NoZero

         legend=legend

        type=mean iframe=black

        raxis=axis1 maxis=axis2

        coutline=black;

run;

View solution in original post


All Replies
Solution
‎02-12-2013 11:41 AM
SAS Employee
Posts: 980

Re: PROC GCHART graphic area problem

Your code seems a bit overly-tricky, using the group= option for what is visually not a grouped bar chart.

I would use the following simplified code instead:

axis1 label=none minor=none order=(0 to 7 by 1) value=none major=none c=white;

axis2 split="," label=none;

pattern color=grayee;

proc gchart data=have; where model='b_gfr';

    vbar measure /

        sumvar=estimate NoZero

        legend=legend

        type=mean iframe=black

        raxis=axis1 maxis=axis2

        coutline=black;

run;

pattern color=gray;

proc gchart data=have; where model = 'd_gfr_10';

    vbar measure /

        sumvar=estimate NoZero

         legend=legend

        type=mean iframe=black

        raxis=axis1 maxis=axis2

        coutline=black;

run;

Super Contributor
Posts: 543

Re: PROC GCHART graphic area problem

Thank you!

:smileygrin:

SAS Employee
Posts: 980

Re: PROC GCHART graphic area problem

I would also recommend using device=png (or device=gif), rather than device=jpeg.

Super Contributor
Posts: 543

Re: PROC GCHART graphic area problem

I was wondering why users prefer the .png to .jpeg?

is there any reason for that?

My graphs tend to look acceptable in jpeg, and eventually when time gets to publish I make .eps or .tiff...

If you have more thoughts on this, I would appreciate your opinion.

Thank you in advance.

SAS Employee
Posts: 980

Re: PROC GCHART graphic area problem

The jpeg format is more geared towards photographs, and can produce "blurry" looking graphs & charts (or at least that's been my experience).

The png or gif formats are better for creating "crisp" looking graphs & charts.   Also, png supports anti-aliasing (of text & lines) and supports millions of colors.  I recommend using png.

SAS Employee
Posts: 980

Re: PROC GCHART graphic area problem

Or, in the words of our developer who works on the SAS jpeg driver ...

"The JPEG format is by nature more suited to reproducing photographic images than

business graphics due to the lossy compression method used.  PNG, TIFF, and GIF

are better format choices for plots, charts, and other business graphic

drawings.  It is possible to clean up JPEG images a little by increasing the image

quality setting to 100 per cent (using the new jpegquality system option)."

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 298 views
  • 6 likes
  • 2 in conversation