BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AncaTilea
Pyrite | Level 9

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.


1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

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

6 REPLIES 6
GraphGuy
Meteorite | Level 14

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;

AncaTilea
Pyrite | Level 9

Thank you!

:smileygrin:

GraphGuy
Meteorite | Level 14

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

AncaTilea
Pyrite | Level 9

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.

GraphGuy
Meteorite | Level 14

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.

GraphGuy
Meteorite | Level 14

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)."

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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