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

Is it possible to create a histgram with only 2 uneven bins: ">= median"  and  "< median" ?  Using either proc univariate, or sgplot.  How to set the middle or endpoint?  Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Super User

What do you mean by endpoints? If I understand you correctly, you can do something like this

 

proc sql;
   create table temp as
   select *, 
   median(height),
   (case
      when height lt median(height) then "< median"
      when height ge median(height) then ">= median"
     end) as overunder
   from sashelp.class;
quit;

proc sgplot data=temp;
   vbar overunder;
run;

View solution in original post

2 REPLIES 2
PeterClemmensen
Super User

What do you mean by endpoints? If I understand you correctly, you can do something like this

 

proc sql;
   create table temp as
   select *, 
   median(height),
   (case
      when height lt median(height) then "< median"
      when height ge median(height) then ">= median"
     end) as overunder
   from sashelp.class;
quit;

proc sgplot data=temp;
   vbar overunder;
run;
Reeza
Super User

@HappySASUE wrote:

Is it possible to create a histgram with only 2 uneven bins: ">= median"  and  "< median" ?  Using either proc univariate, or sgplot.  How to set the middle or endpoint?  Thanks


Sure, that's just a bar chart though, I wouldn't call it a histogram. And in theory, it should be a straight line because that's the definition of the median. 

 

 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 551 views
  • 3 likes
  • 3 in conversation