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;
@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.
@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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.