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

I have 2 variables and I am looking to investigate the relationship between them. First of all, I am working with an excel sheet containing n=4533 observations. Of these observations, each can be categorized into a value between 1-8 known as 'admgrp' (admin group). This is the first variable. 
The second variable is called 'los' (length of stay in days), for which every observation has a value. 
Basically, I want to look at how 'admgrp' value influences the 'los' value. 
I have isolated each 'admgrp' and found their mean 'los' using the attached code;

data SOR2002.admgrp1;
set SOR2002.elderly5;
if admgrp = '1';
run;   proc means data=SOR2002.admgrp1; run;



Where SOR2002.elderly5 is the data set containing all 4533 observations. The above code demonstrates how I isolated admgrp 1, with similar code used to isolate the other 7 admgrps. I then use proc means on each individual admgrp to find their respective means for 'los'. 

Now what I want to do is produce a bar graph showing each admgrp along the horizontal axis against their mean 'los' along the vertical axis.
I assume my first step would be trying to produce a 2-column table; one containing the 8 admgrps and the other containing their 8 respective mean 'los'. I am unsure how to do this. 

Is there some way perhaps that you can produce a new variable called 'average los' and then set it equal to some calculation which returns the mean for each admgrps 'los'? Or is there a way to do it involving the proc means statement? Any advice is appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

 

Proc sgplot data=set SOR2002.elderly5;

   vbar admgrp  /response=los stat=mean;

run;

 

Will create chart with the bars for each value of admgrp and display the mean of the LOS for the group as the height of the bar.

 

The graphing procedures don't have the ability to do a great deal of summaries but can do means, counts (frequency), medians, sums and percentages(carefully).

View solution in original post

1 REPLY 1
ballardw
Super User

 

Proc sgplot data=set SOR2002.elderly5;

   vbar admgrp  /response=los stat=mean;

run;

 

Will create chart with the bars for each value of admgrp and display the mean of the LOS for the group as the height of the bar.

 

The graphing procedures don't have the ability to do a great deal of summaries but can do means, counts (frequency), medians, sums and percentages(carefully).

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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