BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ksharp
Super User

OK. I made a sample data for running my code.

 


data score_card;
call streaminit(123);
 do i=1 to 10000;
  *total_score=rand('integer',400,600);
  total_score=int(rand('uniform')*200) + 400;
  output;
 end;
drop i;
run;

proc sql noprint;
select min(total_score)  ,max(total_score) into :score_min, :score_max from score_card;
quit;


/****** Get cutpoint ******/
proc delete data=cutpoint;run;
%macro cutpoint;
%do score=&score_min %to &score_max;
data test_total_score;
 set score_card;
 _status=ifc(total_score ge &score,'good','bad ');
run;
proc npar1way data=test_total_score edf noprint;
class _status;
var total_score;
output out=cutpoint_ks(keep=_KS_) edf;
run;
data temp_cutpoint;
 retain cutpoint &score ;
 set cutpoint_ks ;
 label cutpoint='分割点' _ks_='KS值';
run;
proc append base=cutpoint data=temp_cutpoint force;run;
%end;
%mend;

%cutpoint

proc sql noprint;
select cutpoint into : cutpoint
 from cutpoint
  having _KS_=max(_KS_);
quit;

data final_total_score;
 set score_card;
call streaminit(123);
good_bad=ifc(rand('bern',0.2),'bad','good');
run; proc sgpanel data=final_total_score; panelby good_bad/layout=rowlattice onepanel noborder novarname; histogram total_score; refline &cutpoint /axis=x; run;
NKormanik
Barite | Level 11

Wow.

 

Who can top THAT?!

 

Well, without further ado, I declare @Ksharp The Solution.

 

Not necessarily for the problem at hand.  But just in general.

 

Thanks so much to all of you that contributed.

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 31 replies
  • 1213 views
  • 26 likes
  • 6 in conversation