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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.