BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
AIO
Calcite | Level 5 AIO
Calcite | Level 5

I used proc sgpanel to create multiple plots. I need to separate Y axis then the plot will be like the plot using GTL. Could proc sgpanel make it? (I know we can let COLUMN=1 to separate  Y axis, it it makes the two plots not in one row which is not same with the attached plot created by GTL ).

AIO_1-1653902965789.png

 

My codes:

 

title "";


proc format;
    value pctcat
        1=">10%"
        2=">1% - 10%"
        3=">0.1 - 1%"
        4="<=0.1%"
    ;
run;

data dummy1;
    do paramcd="CD1", "CD2";
        do cat=1 to 4;
            output;
        end;
    end;
run;

data dummy;
    set dummy1;
    length cd1 cd2 $200;
    if paramcd="CD1" then cd1=put(cat,pctcat.);
    if paramcd="CD2" then cd2=put(cat,pctcat.);

    input n pct;
    pct=pct/100;
    datalines;
    57 53
    30 67
    42 60 
    58 91
    74 78
    32 90
    44 83
    61 93
    ;

run;
ods graphics on /reset width=6in height=5in;

proc sgpanel data=dummy pctlevel=graph;
    panelby paramcd/*/columns=1*/;
    vbar cat/response=n;
    format cat pctcat.;
run;

ods graphics off;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

A panel of plots typically puts the axes on a common scale. It looks like you want the Y axes to scale independently.

 

To emulate the behavior of PROC SGPANEL, you can use the 

ODS LAYOUT GRIDDED

statement to arrange a set of plots that are produced by using PROC SGPLOT.  You can use the 
BY statement in PROC SGPLOT to produce a set of plots, each of which will have an independently scaled Y axis.

 

For example:

/* use PROC SORT, if necessary, to sort the data by the BY group */

ods graphics on /reset width=3in height=5in;
ods layout gridded columns=2 advance=BYGroup column_gutter=5px;
proc sgplot data=dummy;
    by paramcd;
    vbar cat/response=n;
    format cat pctcat.;
run;
ods layout end;

 

View solution in original post

1 REPLY 1
Rick_SAS
SAS Super FREQ

A panel of plots typically puts the axes on a common scale. It looks like you want the Y axes to scale independently.

 

To emulate the behavior of PROC SGPANEL, you can use the 

ODS LAYOUT GRIDDED

statement to arrange a set of plots that are produced by using PROC SGPLOT.  You can use the 
BY statement in PROC SGPLOT to produce a set of plots, each of which will have an independently scaled Y axis.

 

For example:

/* use PROC SORT, if necessary, to sort the data by the BY group */

ods graphics on /reset width=3in height=5in;
ods layout gridded columns=2 advance=BYGroup column_gutter=5px;
proc sgplot data=dummy;
    by paramcd;
    vbar cat/response=n;
    format cat pctcat.;
run;
ods layout end;

 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 431 views
  • 3 likes
  • 2 in conversation