Hi There,
First, let's assume that you have working code that accurately creates the data set LOAN_11. There are several areas where the syntax is questionable, so it may have been copied incorrectly in the posted code.
The SUM function does not summarize across observations. It sums up within a single observation only. To get the rate that you are asking for, I would guess you are looking for:
proc means data=loan_11 mean;
var loan_status2;
run;
The mean value for LOAN_STATUS2 will be the percent of loans that are in default.
As a general rule, think about using a procedure, not a DATA step, to summarize across observations.
First, let's assume that you have working code that accurately creates the data set LOAN_11. There are several areas where the syntax is questionable, so it may have been copied incorrectly in the posted code.
The SUM function does not summarize across observations. It sums up within a single observation only. To get the rate that you are asking for, I would guess you are looking for:
proc means data=loan_11 mean;
var loan_status2;
run;
The mean value for LOAN_STATUS2 will be the percent of loans that are in default.
As a general rule, think about using a procedure, not a DATA step, to summarize across observations.
Thank you very much Super User. It worked fine.
If you have listed all of the values for loan_status in your code you might find this interesting.
proc format; value $default 'Late (31-120 Days)', 'Default' ='In Default' 'Current', 'Late (16-30 Days)', 'In Grace Period', 'Charged Off', 'Fully Paid' = 'Not Default' ; run; proc freq data=Loan_1; tables loan_status; format loan_status $default.; run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.