BookmarkSubscribeRSS Feed
david27
Quartz | Level 8

Hello,

 

How to get the lower and upper boundary limits of the bucket inside a dataset that is result of proc HPBIN?

 

proc hpbin data=sashelp.cars  numbin=10 output=out_bin quantile ;
input mpg_city;
id mpg_city;
run;

If you run the above code you will get the below in results:

 

I want the Range in a dataset. How can i do that?

HPBIN_Output.PNG

 

6 REPLIES 6
Reeza
Super User
https://blogs.sas.com/content/iml/2017/01/09/ods-output-any-statistic.html

Search for OUT/OUTPUT statements on the PROC statement itself as well in the documentation, but the ODS tables are usually quite good.
david27
Quartz | Level 8

Well, Not in this case-- it seems like it.

 

THe out dataset has 2 variables:

1. actual MPG_City variable

2. BIN_MPG_City: This variable has the Bin number for that particular mpg_city.

 

I am looking for a way to get the lower and upper bounds in a dataset.

 

Reeza
Super User
What does your code currently look like?
Reeza
Super User

It worked fine for me using the ODS table, you can use SCAN() to split the range since it's the text so it's a slight extra step but not too bad IMO.


EDIT: I stand corrected, it has the LB and UB in the table as well.

 

Obs	Variable	BinnedVariable	LB	UB	Range	Bin	Frequency	Proportion
1	MPG_City	BIN_MPG_City	.	15.5	MPG_City < 15.5	1	48	0.11214953
2	MPG_City	BIN_MPG_City	15.5	17.5	15.5 <= MPG_City < 17.5	2	72	0.16822430
3	MPG_City	BIN_MPG_City	17.5	18.5	17.5 <= MPG_City < 18.5	3	69	0.16121495
4	MPG_City	BIN_MPG_City	18.5	19.5	18.5 <= MPG_City < 19.5	4	37	0.08644860
5	MPG_City	BIN_MPG_City	19.5	20.5	19.5 <= MPG_City < 20.5	5	57	0.13317757
6	MPG_City	BIN_MPG_City	20.5	21.5	20.5 <= MPG_City < 21.5	6	38	0.08878505
7	MPG_City	BIN_MPG_City	21.5	23.5	21.5 <= MPG_City < 23.5	7	25	0.05841121
8	MPG_City	BIN_MPG_City	23.5	26.5	23.5 <= MPG_City < 26.5	8	53	0.12383178
9	MPG_City	BIN_MPG_City	26.5	.	26.5 <= MPG_City	9	29	0.06775701
david27
Quartz | Level 8

Can you please give the code you used to produce this result?

 

My code looks like:

proc hpbin data=_temp_  numbin=10 output=out_bin quantile ;
input ficeclv9_score;
id ficeclv9_score;
run;
Reeza
Super User
Follow the process in the link in my initial response.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 6 replies
  • 1679 views
  • 0 likes
  • 2 in conversation