BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Toni2
Lapis Lazuli | Level 10

i want to produce Information Value (IV) for a continuous variable using the proc hpbin

 

However, i need to estimate the IV per monthid and not sure how to group by in the hpbin procedure

 

Below is an example how my data looks like and at the bottom it is my code

 

MonthID Var1 Var2
1 1 1
1 2 1
2 3 0
2 4 0
2 5 1
3 6 0
3 7 0
4 8 1
4 9 1
4 10 1
5 11 1
5 12 1

 

 

 

 

 

 

 

 

 

 

 

 


%macro IV_continuous;

	proc hpbin data = data1 numbin = 10;
		input var1;
		ods output mapping = binning;
	run;

	proc hpbin data = data1 woe bins_meta=binning;
		target var2;
		ods output infovalue = continuous_iv_10 woe =continuous_woe_table_10;
	run;

%mend;
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@Toni2 wrote:
Thanks. It looks challenging as i have 50 variables and 80 months. Can I use something like %do i=1 %to 80 months inside hpbin?

Then you should be dynamically generating your variable list and month list.

 

SASHELP.VCOLUMN -> contains a list of variables in your data set, can filter by type

PROC FREQ/SQL to get a list of distinct month. 

Cross join the two lists via SQL to create a table of all combinations you need to run this for. This will be your two parameters to each macro call.


Then use CALL EXECUTE to call the macro for all combinations needed.

 

 

View solution in original post

3 REPLIES 3
Reeza
Super User
From the docs it doesn't look like HPBIN supports BY group processing, which makes some sense for HP procedures. You likely to need to add a WHERE clause to the procedure to have it filter the data for each month as you pass it in.
Toni2
Lapis Lazuli | Level 10
Thanks. It looks challenging as i have 50 variables and 80 months. Can I use something like %do i=1 %to 80 months inside hpbin?
Reeza
Super User

@Toni2 wrote:
Thanks. It looks challenging as i have 50 variables and 80 months. Can I use something like %do i=1 %to 80 months inside hpbin?

Then you should be dynamically generating your variable list and month list.

 

SASHELP.VCOLUMN -> contains a list of variables in your data set, can filter by type

PROC FREQ/SQL to get a list of distinct month. 

Cross join the two lists via SQL to create a table of all combinations you need to run this for. This will be your two parameters to each macro call.


Then use CALL EXECUTE to call the macro for all combinations needed.

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3 replies
  • 1563 views
  • 2 likes
  • 2 in conversation