Hello SAS community,
I am looking for resources on how to compute jacknife estimate of a parameter using BY processing. For example, at the end of the execution, I hope to have the jacknife estimate of treatment effect (treat) for N=4 and effects=0.15, jacknife estimate for N=4 and effects=0.20, jacknife estimate for N=4 and effects=0.3, etc. These will then be used to compute the corresponding Acceleration factor for each of these BY processing. Example, toy data are below for N=4,6, and effects=0.15, 0.20, 0.30. I tried the following SAS code, but it appears not to be giving me what I want. The %jack() macro is from the SAS jackboot macro. If there is a way to generate the jacknife samples with SURVEYSELECT Procedure, that will simplify analysis. Any help is appreciated.
Thanks.
%ODSOff ;
ods output estimates=est;
proc glm data=chg;
class treat;
model post= b treat ;
estimate "difference" treat 1 -1;
by N effects;
run;
%let by=N effects;
%ODSOff ;
%macro analyze(data=,out=);
ods output estimates=&out(where=(parameter eq 'difference') drop=stderr tvalue probt);
proc glm data=&data;
class treat;
model post=b treat ;
estimate "difference" treat 1 -1;
%bystmt;
run;
%mend;
%jack(data=chg, id=parameter);
N | b | treat | effects | post |
---|---|---|---|---|
4 | 6.36910 | 0 | 0.15 | 6.97049 |
4 | 6.52892 | 0 | 0.15 | 7.40859 |
4 | 6.26562 | 1 | 0.15 | 7.56820 |
4 | 7.05193 | 1 | 0.15 | 7.28983 |
4 | 6.36910 | 0 | 0.20 | 6.97049 |
4 | 6.52892 | 0 | 0.20 | 7.40859 |
4 | 6.26562 | 1 | 0.20 | 7.56820 |
4 | 7.05193 | 1 | 0.20 | 7.28983 |
4 | 6.36910 | 0 | 0.30 | 6.97049 |
4 | 6.52892 | 0 | 0.30 | 7.40859 |
4 | 6.26562 | 1 | 0.30 | 7.56820 |
4 | 7.05193 | 1 | 0.30 | 7.28983 |
6 | 6.23206 | 0 | 0.15 | 6.61017 |
6 | 6.56842 | 0 | 0.15 | 6.79354 |
6 | 6.85177 | 0 | 0.15 | 7.60327 |
6 | 6.87010 | 1 | 0.15 | 6.53018 |
6 | 6.48628 | 1 | 0.15 | 7.16911 |
6 | 7.74127 | 1 | 0.15 | 8.13158 |
6 | 6.23206 | 0 | 0.20 | 6.61017 |
6 | 6.56842 | 0 | 0.20 | 6.79354 |
6 | 6.85177 | 0 | 0.20 | 7.60327 |
6 | 6.87010 | 1 | 0.20 | 6.53018 |
6 | 6.48628 | 1 | 0.20 | 7.16911 |
6 | 7.74127 | 1 | 0.20 | 8.13158 |
6 | 6.23206 | 0 | 0.30 | 6.61017 |
6 | 6.56842 | 0 | 0.30 | 6.79354 |
6 | 6.85177 | 0 | 0.30 | 7.60327 |
6 | 6.87010 | 1 | 0.30 | 6.53018 |
6 | 6.48628 | 1 | 0.30 | 7.16911 |
6 | 7.74127 | 1 | 0.30 | 8.13158 |
Due to time constraints, I can only give you a short answer.
You cannot take jackknife samples with PROC SURVEYSELECT. Bootstrap samples, yes, but jackknife samples, no!
Jackknife estimates in SAS
By Rick Wicklin on The DO Loop June 21, 2017
https://blogs.sas.com/content/iml/2017/06/21/jackknife-estimate-standard-error-sas.html
Sample 24982: Jackknife and Bootstrap Analyses
https://support.sas.com/kb/24/982.html
The SURVEYFREQ Procedure
Jackknife Method
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_surveyfreq_details31.htm
Koen
Thanks for your response. These are useful, but they do not address BY processing.
Yeah. @Rick_SAS wrote a blog about it ,you can refer to it ,but they are IML code.
Thanks for your response. But the blog by @Rick_SAS does not accommodate BY processing.
Hello @SWEETSAS ,
There are other blogs by @Rick_SAS that do explain by-group processing (as preferred solution over a macro loop).
Simulation in SAS: The slow way or the BY way
By Rick Wicklin on The DO Loop July 18, 2012
https://blogs.sas.com/content/iml/2012/07/18/simulation-in-sas-the-slow-way-or-the-by-way.html
Don't forget to turn off ODS when you run BY-group processing!
Turn off ODS when running simulations in SAS
By Rick Wicklin on The DO Loop May 24, 2013
https://blogs.sas.com/content/iml/2013/05/24/turn-off-ods-for-simulations.html
Jackknife estimates in SAS
By Rick Wicklin on The DO Loop June 21, 2017
https://blogs.sas.com/content/iml/2017/06/21/jackknife-estimate-standard-error-sas.html
BR,
Koen
Many thanks for your response. After reading the materials, below is the SAS Code I wrote based on my understanding of the materials. Unfortunately, the SAS program is not working. Any help is appreciated.
Here are the steps that might give a clearer picture. The difference between this and the elegant blog by @Rick is that the blog only considers a dataset, or dropping nth level. But here, one is dropping n_th observation in the b_th level.
1) read in the data
2) sort the data by two variables, (effects and treat)
3)extract the sorted categories
4) obtain row numbers for the first observation in each level (i.e., the two BY variables (effects and treat). Using only one variable will wrongly assume fewer levels)
5) find observations in each level
6) create jackknife samples by dropping n_th observation in the b_th level. (Here is the hard part. The nth observation is dropped from the b_th level. Think about it as each level representing a dataset.)
7) create a dataset that has replicate for each jackknife sample.
Thanks
proc iml;
use aa;
read all var{effects treat b post} into m;
close;
call sort(m,1:2); /*sort by effects and treat*/
c=m[,1:2]; /*done with m: extract sorted categories*/
x=m[,3:4]; /*the renaning sorted data*/
/*obstain row numbers for the first observation in each level*/
b=uniqueby(C,1:2); /*b[i]=begining of i_th category. there are 2 BY variables--effects and treat*/
u=c[b]; /*get unique values (if needed)*/
*s=j(nrow(b),1); /*Allocate vector to hold results*/
b=b//(nrow(c)+1); /*trick: append (n+1) to end of b*/
do i=1 to nrow(b)-1;/*For each level....*/
idx=b[i]:(b[i+1]-1);/*Find observations in level*/
idxn=loc(idx ^=b[u]); /*create jackknife samples: remove i_th observation in b_th category*/
ID=colvec(repeat(T(1:b),1,idxn)); /*create ID number for each jackknife same*/
*Group = j(nrow(ID), 1, 2);
Z=ID|||C||X; /*Combine with original data*/
append from Z; /*create dataset Z that contains replicates */
end;
print idx z;
quit;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.