College of Natural Sciences
 
FAQs
This is for IE7 to hold div open

SAS FAQ #37: Jacknife regression using SAS

Question:

I would like to do a multiple regression using the jackknife procedure. That is, I would like to run N regressions, dropping one case each time, and I want the N sets of parameter estimates output to one SAS data set so I can analyze them.

Answer:

The following SAS program performs a jackknife regression. The parameter estimates are stored in a temporary SAS data set named RegEsts. The estimates are generated in a SAS Macro named JackReg. Each loop through JackReg drops one case and runs PROC REG on the remaining cases. Thus the number of loops depends on the number of cases in the data set.

The purpose of the first DATA step is to create a macro variable that contains the number of cases and thus is used to end the DO loop. The SAS function SYMPUT creates this variable (here named NCASES). Include the END= option on the INFILE statement to avoid calling SYMPUT once for each observation. (Note that the first DATA step can use the SET statement, instead of the INFILE and INPUT statements, if your data already exist in a SAS data set. In that case, use the END= option in the SET statement).

The heart of the program, the macro JackReg, is then defined and run.




/*       SAS jackknife regression program.

Input your data in the preliminary DATA step and specify

your model in the MODEL statement within the macro.

*/

  

DATA one ;

   INFILE ' yourraw dataset here'  END=lastcase;

   INPUT  yvar  xvar1  xvar2     xvarm  ;

   IF lastcase THEN CALL SYMPUT ('ncases', _N_) ;

RUN;



*Macro portion of program begins here;

%MACRO JackReg ;

%DO I = 1 %TO &ncases ;

DATA temp&I ;

   SET one ;

   IF  _N_   NE   &I ;

RUN;



PROC REG OUTEST = loopIest ;

   Omits&I:  MODEL  yvar = xvar1  xvarm;

   *Specify your model in the line above;

RUN ;



PROC APPEND BASE = RegEsts  NEW = loopIest ;

RUN ;



%END ;

%MEND JackReg;

*Macro portion of program ends here;



%JackReg;

*this statement actually runs the macro JackReg;

* End of jackknife regression program ;



If you have more questions about performing a jackknife regression using SAS, contact a consultant. The references for this program include: SAS Guide to Macro Processing, Version 6, Second Edition, pp. 65-70; p. 165; SAS/STAT User's Guide, Volume 2, Version 6, Fourth Edition, pp. 1351-1456; and SAS Procedures Guide, Version 6, Third Edition, pp. 43-52 (APPEND procedure). For further information, you can also click on the Help button in the SAS menu bar and scroll to SAS Help and Documentation.

If you have further questions, send E-mail to stats@ssc.utexas.edu.