BookmarkSubscribeRSS Feed
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
lydia_li
Fluorite | Level 6

it means I still need the solution for this:

 

This is before:

lydia_li_1-1656529511903.png

 

and this is after:

lydia_li_2-1656529511840.png

 

 

no change to the last columns for example, and the name will be updated as Bin_XXX. Thanks!

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
lydia_li
Fluorite | Level 6

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.

Tom
Super User Tom
Super User

@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.

Reeza
Super User

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;

 

lydia_li
Fluorite | Level 6

so when the variable is char, how can I use PROC HPBIN to bin char variables? Thanks!

Reeza
Super User

Agreed - wondering if a format may not do whatever is needed instead of needing new variables.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 22 replies
  • 2484 views
  • 4 likes
  • 4 in conversation