BookmarkSubscribeRSS Feed
Sergio_Mora0713
Calcite | Level 5

Hello,

 

       I have multiple univariate histograms that I would like to set next to each other and I can't for the life of me find a way to do so. Attached is the code I am using for an example along with the graphs it creates. I've tried proc sgpanel but I keep getting the same problem.  

 

The goal is ultimately to have a 2x2 set of graphs with the same class variable on the left.

 

 

1 REPLY 1
Rick_SAS
SAS Super FREQ

In your code, you have one binary categorical variable (Married=0|1) and two continuous variables. Are you saying that you want a panel that have each continuous variable in a separate column, and the rows are the levels of Married?

 

If so, convert the data from wide to long and use PROC SGPANEL:

data BWeightLong;
set Sashelp.BWeight(keep=Married Weight MomWtGain);
VarName = "Weight   "; Value = Weight;    output;
VarName = "MonWtGain"; Value = MomWtGain; output;
keep Married VarName Value;
run;


proc sgpanel data=BWeightLong;
panelBy VarName Married / layout=lattice uniscale=row;
histogram Value;
density Value;
run;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 1 reply
  • 962 views
  • 0 likes
  • 2 in conversation