@lydia_li wrote:
thanks, but I still need the solution for changing the value for each column, not just to 1, 1 is an example, so how to do that? Thanks!
I don't know what this means.
it means I still need the solution for this:
This is before:
and this is after:
no change to the last columns for example, and the name will be updated as Bin_XXX. Thanks!
Well, if you are going to compute WOE, you do NOT need this. And I can't think of any good reason to create large numbers of columns where the values are all 1. So, I fall back to my position that just because it is possible to do such a thing does not mean you SHOULD do such a thing. Convince me that you really really really need this.
as I said before, 1 is an example, I want to re-assign some columns, for example PD = 1 or LGD/EAD = 100000 etc. 1 is just an example for understanding.
@lydia_li wrote:
as I said before, 1 is an example, I want to re-assign some columns, for example PD = 1 or LGD/EAD = 100000 etc. 1 is just an example for understanding.
What is the problem with just writing the code?
data want;
set have;
PD = 1;
LGD_EAD = 100000 ;
run;
Note: If you want coding help post your data and code as TEXT and not PICTURES.
Unless you're coding all columns the same, which usually isn't how you bin categories for Weight of Evidence there's no way to simplify this.
Do you have a set of categories you want to test for a set of columns? If so, you can do that via an array.
You'll need to do this separately for character or numeric set of variables.
Here is a reference that illustrates how to refer to variables and datasets in a short cut list that can be used for arrays.
https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html
If you have large set of lists you can generate the new/old names dynamically by querying sashelp.vcolumn to generate them in macro variables.
data want;
set have;
array orig(5) var1 bc1 acb2 ade ref;
array new(5) new1-new5;
do i=1 to 5;
if orig(i) < 100 then new(i) = 1;
else if orig(i) < 200 then new(i) = 2;
....
end;
run;
so when the variable is char, how can I use PROC HPBIN to bin char variables? Thanks!
Agreed - wondering if a format may not do whatever is needed instead of needing new variables.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.