BookmarkSubscribeRSS Feed
the_sheriff
Calcite | Level 5

 

I have used proc template and layout lattice to create two horizontal barchart panels side by side.
I have two consecutive Layout Overlay Barchart lines to create the two barcharts. 

layout overlay

     barchart
endlayout

layout overlay

     barchart

endlayout

 

I also have the correct datarange union so that there is only one set of tick values on the left hand side. So far so good.

My problems begin when i have different numbers of bars in different datasets (the two panels will always have the same number of bars per dataset).

If i have fewer bars, the cells and barwidth expand to fill the space. If i have more bars, the barwidth shrinks to fit in the space. This i can often fix with ODS Graphics height.

I also have a second problem. In one dataset, the tick values on the left are very short and in another dataset the tick values are very long. For the short tick values, the panel width expands to fill the space. And for the longer tick values the panel width shrinks to fit the space.

 

Can i set the panel widths (and height) in stone so that SAS will not change it? 

If i need to switch to sgpanel or layout datapanel, that should not be a problem.

 

Thank you for your help.

2 REPLIES 2
ballardw
Super User

Strong suggestion with any question related to graphics programming: Provide the entire Proc Template and associated Proc Sgrender code. And since your issue involves differing behaviors with different data sets, at least two data sets to demonstrate your current behavior. The example data sets should be small and provided in the form of data step code.

 

If your code uses any custom formats or macro variables then please include the definitions of the formats in proc format code and how the macro variables are created or at least appropriate values.

 

There are so many options that interact within Proc Template that a skeleton and short description is usually going to be insufficient to diagnose and will generally require asking for the details of your code anyway.

 

IF you have something in your code that you think reveals too much about your sensitive data then reduce things to generic variable names and labels.

DanH_sas
SAS Super FREQ

How about something like this:

 

/* Two original data sets with different bar counts and value lengths */
data one;
    do x=1 to 5;
       y=ranuni(123);
       group="Group 1";
       output;
       y=ranuni(123);
       group="Group 2";
       output;
    end;
run;

data two;
    do x=1000 to 3000 by 1000;
    y=ranuni(321);
    group="Group 1";
    output;
    y=ranuni(321);
    group="Group 2";
    output;
 end;
run;

/* Merge the two data datasets with a classifier column */
data one_prime;
    set one;
    name = "one";
run;
data two_prime;
    set two;
    name = "two";
run;
data merged;
    merge one_prime two_prime;
    by name;
run;

proc sgpanel data=merged;
    panelby group name / layout=lattice onepanel proportional uniscale=column novarname;
    hbar x / response=y;
run;

Screenshot 2025-06-13 at 4.58.47 PM.png

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2 replies
  • 887 views
  • 1 like
  • 3 in conversation