<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Logistic regression-calculate pred on out of time data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Logistic-regression-calculate-pred-on-out-of-time-data/m-p/953581#M372528</link>
    <description>In my code:&lt;BR /&gt;ods output parameterestimates=tbl_coefficients;&lt;BR /&gt;&lt;BR /&gt;already save these estimated parameters into dataset named 'tbl_coefficients' .&lt;BR /&gt;&lt;BR /&gt;"can use it in the future on any out of time data set to calculate predictions...??"&lt;BR /&gt;Sure, of course. The following is an example for scoring dataset PANEL:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc transpose data=tbl_coefficients out=tbl_coefficients2 prefix=_;&lt;BR /&gt;var Estimate;&lt;BR /&gt;id Parameter;&lt;BR /&gt;run;&lt;BR /&gt;data score_panel2;&lt;BR /&gt; if _n_=1 then set tbl_coefficients2;&lt;BR /&gt; set panel;&lt;BR /&gt; y_hat=logistic(_intercept+_x*x);&lt;BR /&gt;run;&lt;BR /&gt;</description>
    <pubDate>Sat, 14 Dec 2024 08:36:20 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2024-12-14T08:36:20Z</dc:date>
    <item>
      <title>Logistic regression-calculate pred on out of time data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Logistic-regression-calculate-pred-on-out-of-time-data/m-p/953572#M372522</link>
      <description>&lt;P&gt;Hello friends ,&lt;/P&gt;
&lt;P&gt;I have train data, test data, out of time data.&lt;/P&gt;
&lt;P&gt;There are 3 things I want to do-&lt;/P&gt;
&lt;P&gt;1-calculate model coefficients based on train data&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2-calculate pred valued for each observation train+test data&lt;/P&gt;
&lt;P&gt;3-calculate pred valued for each observation in out of time data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the way to perform task 3 using proc genmod ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that I tried to save the coefficients in a permanents data set (permanent&amp;nbsp; library) but I cannot find this data set&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc genmod data=panel;
ods output parameterestimates=tbl_coefficients;/****Data set with Coeficients information that was calculated from train data only****/
weight weight;
model y=x / dist=binomial link=logit  type3 wald ;
output out=preds_tbl pred=P_BAD XBETA=logit;
store R_R.coefficients;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Data train(KEEP=X Y);
Do i=1 to 50;
x=ranuni(1234579);
p = 0.6;
u = rand("Uniform");
if (u &amp;lt; p) then Y=1;else Y=0;
output;
end;
Run;


Data test(KEEP=X Y);
Do i=1 to 25;
x=ranuni(1234579);
p = 0.6;
u = rand("Uniform");
if (u &amp;lt; p) then Y=1;else Y=0;
output;
end;
Run;

data panel;
set train(in=a) test(in=b);
if a then weight=1;else weight=0;/***Value 1 for train data, value 0 for test data**/
Run;


proc genmod data=panel;
ods output parameterestimates=tbl_coefficients;/****Data set with Coeficients information that was calculated from train data only****/
weight weight;
model y=x / dist=binomial link=logit  type3 wald ;
output out=preds_tbl pred=P_BAD XBETA=logit;
Run;



Data Out_of_time;
Do i=1 to 200;
x=ranuni(1234579);
p = 0.6;
u = rand("Uniform");
if (u &amp;lt; p) then Y=1;else Y=0;
output;
end;
Run;
/**I want to calculate pred on this data of out of time***/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2024 07:16:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Logistic-regression-calculate-pred-on-out-of-time-data/m-p/953572#M372522</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-12-14T07:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: Logistic regression-calculate pred on out of time data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Logistic-regression-calculate-pred-on-out-of-time-data/m-p/953578#M372526</link>
      <description>&lt;P&gt;&lt;SPAN&gt;1-calculate model coefficients based on train data&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Data train(KEEP=X Y);
Do i=1 to 50;
x=ranuni(1234579);
p = 0.6;
u = rand("Uniform");
if (u &amp;lt; p) then Y=1;else Y=0;
output;
end;
Run;


Data test(KEEP=X Y);
Do i=1 to 25;
x=ranuni(1234579);
p = 0.6;
u = rand("Uniform");
if (u &amp;lt; p) then Y=1;else Y=0;
output;
end;
Run;

data panel;
set train test;
Run;


proc genmod data=train;
ods output parameterestimates=tbl_coefficients;
model y=x / dist=binomial link=logit  type3 wald ;
 store PainModel ;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2-calculate pred valued for each observation train+test data&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc plm restore=PainModel;
   score data=panel out=Score_panel predicted LCLM UCLM / ilink; /* ILINK gives probabilities */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;3-calculate pred valued for each observation in out of time data&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Data Out_of_time;
Do i=1 to 200;
x=ranuni(1234579);
p = 0.6;
u = rand("Uniform");
if (u &amp;lt; p) then Y=1;else Y=0;
output;
end;
Run;

proc plm restore=PainModel;
   score data=Out_of_time out=Score_Out_of_time predicted LCLM UCLM / ilink; /* ILINK gives probabilities */
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Dec 2024 08:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Logistic-regression-calculate-pred-on-out-of-time-data/m-p/953578#M372526</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-12-14T08:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Logistic regression-calculate pred on out of time data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Logistic-regression-calculate-pred-on-out-of-time-data/m-p/953579#M372527</link>
      <description>Thank you. Is it possible to save the coefficients in a permanent data set and then can use it in the future on any out of time data set to calculate predictions...??</description>
      <pubDate>Sat, 14 Dec 2024 08:19:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Logistic-regression-calculate-pred-on-out-of-time-data/m-p/953579#M372527</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-12-14T08:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: Logistic regression-calculate pred on out of time data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Logistic-regression-calculate-pred-on-out-of-time-data/m-p/953581#M372528</link>
      <description>In my code:&lt;BR /&gt;ods output parameterestimates=tbl_coefficients;&lt;BR /&gt;&lt;BR /&gt;already save these estimated parameters into dataset named 'tbl_coefficients' .&lt;BR /&gt;&lt;BR /&gt;"can use it in the future on any out of time data set to calculate predictions...??"&lt;BR /&gt;Sure, of course. The following is an example for scoring dataset PANEL:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc transpose data=tbl_coefficients out=tbl_coefficients2 prefix=_;&lt;BR /&gt;var Estimate;&lt;BR /&gt;id Parameter;&lt;BR /&gt;run;&lt;BR /&gt;data score_panel2;&lt;BR /&gt; if _n_=1 then set tbl_coefficients2;&lt;BR /&gt; set panel;&lt;BR /&gt; y_hat=logistic(_intercept+_x*x);&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Sat, 14 Dec 2024 08:36:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Logistic-regression-calculate-pred-on-out-of-time-data/m-p/953581#M372528</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-12-14T08:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Logistic regression-calculate pred on out of time data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Logistic-regression-calculate-pred-on-out-of-time-data/m-p/953582#M372529</link>
      <description>&lt;P&gt;It's a lot easier if you use PROC LOGISTIC instead of PROC GENMOD. There doesn't seem to be a reason in your problem description that you would have to use GENMOD.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc logistic data=train ... ;
    model y = x1 x2 ... ;
    score data=train out=trainpreds;
    score data=test out=testpreds;
    score data=outoftime out=outoftimepreds;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Dec 2024 10:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Logistic-regression-calculate-pred-on-out-of-time-data/m-p/953582#M372529</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-12-14T10:29:11Z</dc:date>
    </item>
  </channel>
</rss>

