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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 1 reply
  • 764 views
  • 0 likes
  • 2 in conversation