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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 830 views
  • 0 likes
  • 2 in conversation