Programming the statistical procedures from SAS

What's the easiest way to create an estimate variable based on the coefficients from a model?

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

What's the easiest way to create an estimate variable based on the coefficients from a model?

Hi all-

If I run a model (i'm using Proc Logistic), and I then want to use that same equation, is there an easy way to do it?

I am trying to validate my model on a subsample of my data.

Right now, I'm taking the parameters output data set, transposing it, then using PUT statements to write it to a file, which i then read back in as a single variable that I save to a macro variable. Then I use that macro variable in a data set. It's a bit of an ordeal, and the use of an external file made me think there must be a better way of doing this. 

Your input is appreciated!

Here's the code equivalent from what I did:

options lrecl = 1000 ;
data _null_;
     set transparm (where = (_NAME_ ne '_LNLIKE_')) end = eof ;
     file "LogRegFunc.txt" ; 

     if lowcase(_NAME_) eq 'intercept' then
          do ;
               put coeff "+ " @@ ;
          end ;
     else
          do ;
               if not(eof) then
                    do ;
                         put "(" coeff "* " _NAME_ +(-1) ") + " @@ ;
                    end ;
               else if (eof) then
                    do ;
                         put "(" coeff "* " _NAME_ +(-1) ")" ;
                    end ;
          end ;
run ;

data _null_ ;
     infile "LogRegFunc.txt" ;
     length equation $1000. ;
     input ;
     equation = _infile_ ;
     call symputx('LogRegEq', equation) ;
run ;


data predicted;
     set model_out ;

     if validation then
          do ;
               v_log_est = &LogRegEq ;
               v_upg_rate = exp(v_log_est)/(1-exp(v_log_est)) ;
          end ;

     if rel_mth eq 45 then v_upg_rate = v_upg_rate ;

run ;


Accepted Solutions
Solution
‎10-28-2013 05:09 PM
Grand Advisor
Posts: 16,926

Re: What's the easiest way to create an estimate variable based on the coefficients from a model?


All Replies
Solution
‎10-28-2013 05:09 PM
Grand Advisor
Posts: 16,926

Re: What's the easiest way to create an estimate variable based on the coefficients from a model?

The term is SCORING a dataset.

See the example under proc logistic:

http://support.sas.com/documentation/cdl/en/statug/63962/HTML/default/viewer.htm#statug_logistic_sec...

Example 53.15

Contributor
Posts: 25

Re: What's the easiest way to create an estimate variable based on the coefficients from a model?

Thanks Reeza!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 151 views
  • 0 likes
  • 2 in conversation