I can calculate the motion of heavenly bodies but not the madness of people. -Isaac Newton

## SAS Macro Aligning The Logit Variable to A Scorecard with Specific PDO and Base Point

```%macro align_score(data = , y = , logit = , pdo = , base_point = , base_odds = , min_point = 100, max_point = 900);
***********************************************************;
* THE MACRO IS TO ALIGN A LOGIT VARIABLE TO A SCORE WITH  *;
* SPECIFIC PDO, BASE POINT, AND BASE ODDS                 *;
* ======================================================= *;
* PAMAMETERS:                                             *;
*  DATA      : INPUT SAS DATA TABLE                       *;
*  Y         : PERFORMANCE VARIABLE WITH 0/1 VALUE        *;
*  LOGIT     : A LOGIT VARIABLE TO BE ALIGNED FROM        *;
*  PDO       : PDO OF THE SCORE ALIGNED TO                *;
*  BASE_POINT: BASE POINT OF THE SCORE ALIGNED TO         *;
*  BASE_ODDS : ODDS AT BASE POINT OF THE SCORE ALIGNED TO *;
*  MIN_POINT : LOWER END OF SCORE POINT, 100 BY DEFAULT   *;
*  MAX_POINT : UPPER END OF SCORE POINT, 900 BY DEFAULT   *;
* ======================================================= *;
* OUTPUTS:                                                *;
*  ALIGN_FORMULA.SAS                                      *;
*  A SAS CODE WITH THE FORMULA TO ALIGN THE LOGIT FIELD   *;
*  TO A SPECIFIC SCORE TOGETHER WITH THE STATISTICAL      *;
*  SUMMARY OF ALIGN_SCORE                                 *;
***********************************************************;

options nocenter nonumber nodate mprint mlogic symbolgen
orientation = landscape ls = 150 formchar = "|----|+|---+=|-/\&lt;&gt;*";

%local b0 b1;

data _tmp1 (keep = &amp;y &amp;logit);
set &amp;data;
where &amp;y in (0, 1) and &amp;logit ~= .;
run;

ods listing close;
ods output ParameterEstimates = _est1 (keep = variable estimate);
proc logistic data = _last_ desc;
model &amp;y = &amp;logit;
run;
ods listing;

data _null_;
set _last_;

if _n_ = 1 then do;
b = - (estimate + (log(&amp;base_odds) - (log(2) / &amp;pdo) * &amp;base_point)) / (log(2) / &amp;pdo);
call symput('b0', put(b, 15.8));
end;
else do;
b = estimate / (log(2) / &amp;pdo);
call symput('b1', put(b, 15.8));
end;
run;

filename formula "ALIGN_FORMULA.SAS";

data _null_;
file formula;

put @3 3 * "*" " SCORE ALIGNMENT FORMULA OF %upcase(&amp;logit) " 3 * "*" ";";
put;
put @3 "ALIGN_SCORE = MAX(MIN(ROUND((%trim(&amp;b0)) - (%trim(&amp;b1)) * %upcase(&amp;logit), 1), &amp;max_point), &amp;min_point);";
put;
run;

data _tmp2;
set _tmp1;
%inc formula;
run;

proc summary data = _last_ nway;
class &amp;y;
output out = _tmp3(drop = _type_ _freq_)
min(align_score) = min_scr max(align_score) = max_scr
median(align_score) = mdn_scr;
run;

data _null_;
set _last_;
file formula mod;

if _n_ = 1 then do;
put @3 3 * "*" " STATISTICAL SUMMARY OF ALIGN_SCORE BY INPUT DATA: " 3 * "*" ";";
end;
put @3 "* WHEN %upcase(&amp;y) = " &amp;y ": MIN(SCORE) = " min_scr " MEDIAN(SCORE) = " mdn_scr " MAX(SCORE) = " max_scr "*;";
run;

proc datasets library = work nolist;
delete _: (mt = data);
run;
quit;

***********************************************************;
*                     END OF THE MACRO                    *;
***********************************************************;
%mend align_score;
```