From: Subject: Date: Fri, 16 Mar 2012 12:13:20 +1100 MIME-Version: 1.0 Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Content-Location: http://members.iinet.net.au/~brucebra/code/utility/ABSJackExample.sas X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109
* Replicating (parts of) tables 5.2 and 5.4 from=20
  ABS (2002), Household Expenditure Survey, Australia, Confidentialised =
Unit
  Record File (CURF) Technical Paper, Second Edition (incl Fiscal =
Incidence Study)
  August 2002. Cat No. 6544.0.30.001;
* This program uses the ABSJack.sas file in the SASAuto library;
* You might need to change these two lines;
libname HES "I:\DataR\ABS\HES98-99\V3";
%fsadd(hes.formats); /* puts format library in search list */
* working data file;
data input;
set hes.hes98hsh;
One1000 =3D 1/1000;
array expenditure(*) exp01--extlcser;
do i=3D1 to dim(expenditure);
  expenditure(i)=3Dexpenditure(i)/100;
end;
array weight(*) wt finwgt1--finwgt30;
do i=3D1 to dim(weight);
  weight(i)=3Dweight(i)/10000;
end;
keep  One1000 states exp01--extlcser wt finwgt1--finwgt30;
run;
* define analysis macro that produces results for a particular weight;
%macro analyse(data=3D,results=3D,weight=3D,print=3D);
proc means data=3D&data &print;
  weight &weight;
  class states;
  var exp01; /* arbitrary variable */
  output out=3D&results
         mean(exp01--extlcser)=3D sum(One1000)=3DHHPop =
n(exp01)=3DHHsample;
run;
%mend analyse;
*run this to test;
%analyse(data=3Dinput,results=3Dmeans,weight=3Dwt,print=3Dprint);
* print in layout similar to ABS table ;
data means;set means;if states=3D. then states=3D99;run;
proc tabulate data=3Dmeans noseps missing;
  class states;
  var exp01--extlcser hhpop hhsample;
  label hhpop=3D"Number of HH in population";
  label hhsample=3D"Number of HH in sample";
  table sum=3D""*(%repi(exp[i],01,17) extlcser)*f=3D6.2=20
        sum=3D""*(hhpop )*f=3Dcomma6.1
        sum=3D""*(hhsample)*f=3Dcomma4.0,states /row=3Dfloat rts=3D50 ;
  run;
* use these options to reduce log output if everything is working =
smoothly;
options msglevel=3DN nonotes;
* now run jackknife macro;
%absjack(data=3Dinput,w0=3Dwt,prefix=3Dfinwgt,nrep=3D30,
           id=3Dstates,
           stat=3Dexp01--extlcser hhpop hhsample,
           print=3Dnoprint);
* print in layout similar to ABS table ;
* Note however, that the variables are in alpha order rather than the =
original
  order;
data summary;set ABSJack_output;if states=3D. then states=3D99;run;
proc tabulate data=3Dsummary noseps missing;
  class states _name_ _label_;
  var value rse;
  table _name_=3D""*_label_=3D"",
        sum=3D""*value*f=3D6.2*states /row=3Dfloat rts=3D60 ;
  table _name_=3D""*_label_=3D"",
        sum=3D""*rse*f=3D6.2*states /row=3Dfloat rts=3D60 ;
  run;