BookmarkSubscribeRSS Feed
edasdfasdfasdfa
Quartz | Level 8

Hello,

 

Hey there,

 

I did a search, trying to see how to create lift charts (preferably along with proc logistic) but can't seem to find any info. 

 

Regards,

2 REPLIES 2
SASKiwi
PROC Star

I believe PROC LOGISTIC can do these with the appropriate statements. Check out the ROC Curve listing in this link: 

http://support.sas.com/kb/30/333.html#roc

Ksharp
Super User

NOTE: the code is not written by me . I stole it from somewhere.

 

/*******
  Credit Risk Scorecards: Development and Implementation using SAS
  (c)  Mamdouh Refaat
********/


/*******************************************************/
/* Macro LiftChart  */
/*******************************************************/

%macro LiftChart(DSin, ProbVar, DVVar, DSLift);
/* Calculation of the Lift chart data from 
   the predicted probabilities DSin using 
   the PorbVar and DVVar. The lift chart data
   is stored in DSLift. We use 10 deciles. 
*/

/* Sort the observations using the predicted Probability in descending order*/
proc sort data=&DsIn;
	by descending &ProbVar;
run;

/* Find the total number of Positives */
%local P Ntot;
proc sql noprint;
	select sum(&DVVar) into:P from &DSin;
	select count(*) into: Ntot from &DSin;
quit;
%let N=%eval(&Ntot-&P); /* total Negative(Good) */

/* Get Count number of correct defaults per decile */
data &DSLift;
	set &DsIn nobs=nn ;
	by descending &ProbVar;
	retain Tile 1  SumP 0 TotP 0 SumN 0 TotN 0;
	Tile_size=ceil(NN/10);

	TilePer=Tile/10;

	label TilePer ='Percent of Population';
	label TileP='Percent of population';

	if &DVVar=1 then SumP=SumP+&DVVar;
	else SumN=SumN+1;

	PPer=SumP/&P;			/* Positive  %    */
	NPer=SumN/&N;           /* Negative % */

	label PPer='Percent of Positives';
	label NPer='Percent of Negatives';

	if _N_ = Tile*Tile_Size then 	do;
		output;
		if Tile <10 then  Tile=Tile+1;
	end;	

	keep TilePer PPer NPer;
run;

/* Add the zero value to the curve */
data temp;
 	TilePer=0;
	PPer=0;
	NPer=0;
run;
Data &DSLift;
  set temp &DSlift;
run;
%mend;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1400 views
  • 0 likes
  • 3 in conversation