BookmarkSubscribeRSS Feed
Loredov
Calcite | Level 5

Hi there,

 

I'm new at using SAS so maybe my problem is easy to solve. I'm trying to implement a jackknife approach in a GLM analysis. For this purpose, I used the jackknife macro https://support.sas.com/kb/24/982.html so that the code was (variables in the model are not real, just to make it easy to read):

 

%macro analyze (data=, out=);
PROC GLM DATA= GLM;
MODEL Y = X + Z;
out=out(rename=(_type_=stat _name_=with));
%bystmt;
RUN;
%mend;
%inc "C:\route to macro";
   %jack(data=GLM,id=stat with)
 
When running the syntax, two errors appeared: WORK.JACKDIST.DATA does not exist and WORK.JACKACT.DATA does not exist.
 
Any help?
 
thanks in advance
4 REPLIES 4
ballardw
Super User

You have likely oversimplified things.

You should provide at an absolute minimum the the macro call that you used.

Best would be to copy the call from the LOG along with the error message(s) and paste into a code box opened on the forum with the </> icon to preserve formatting of the messages.

 

If the macro call looked like:

%jackdist(data=jackdist,<other parameters here>)

then you do not have a data set named Jackdist in the WORK library.

You may either need to add the library name to the data set such as

 

%jackdist(data=mylib.jackdist, <other parameters>)

or you need to check the spelling of the data set name that you provided.

It is very likely the second data set missing could be that the result was supposed to be created but if it was a parameter to the macro call then the same issues apply.

FreelanceReinh
Jade | Level 19

Hi @Loredov and welcome to the SAS Support Communities!

 

Before trying to run your own code (the PROC GLM step in this case) in a macro, you should run it outside a macro and make sure that the desired output is produced and the log is "clean" (no error messages, warnings, etc.). In your example you would notice that

  1. The syntax of the MODEL statement must not contain plus signs (but maybe your real code uses correct syntax, i.e. Y = X Z).
  2. There is no OUT= statement in PROC GLM, only an OUT= option of the OUTPUT statement, but that output dataset would normally not contain variables named _type_ or _name_.

I guess you copied the OUT= option from the example using PROC CORR, but the syntax of PROC GLM is different.

 

Also, the dataset names, GLM and out in your example, must not be hardcoded, but replaced by macro variable references &data and &out, respectively. Otherwise, macro jack cannot create the datasets JACKDIST and JACKACT, which causes the error messages you've reported.

 

Here's an example that works:

proc glm data=sashelp.class;
model weight=height age;
quit;

Now let's compute jackknife estimates of, say, the parameter estimates of height and age in the above linear regression.

%macro analyze(data=,out=);
ods output parameterestimates=&out(where=(parameter ne 'Intercept') drop=stderr tvalue probt);
proc glm data=&data;
model weight=height age;
%bystmt;
run;
%mend;

%jack(data=sashelp.class, id=parameter)

In this case, the statistics of interest are contained in an ODS output dataset, which is requested with an ODS OUTPUT statement. By default, this output dataset would look like this:

Dependent    Parameter        Estimate          StdErr     tValue     Probt

 Weight      Intercept    -141.2237635     33.38309350      -4.23    0.0006
 Weight      Height          3.5970265      0.90546072       3.97    0.0011
 Weight      Age             1.2783925      3.11010374       0.41    0.6865

We see that variable Parameter is suitable for identifying the observations of interest, hence it is specified in the second parameter in the %jack macro call. The first observation will be excluded (arbitrarily) by the WHERE= dataset option. The last three variables are excluded by the DROP= dataset option because we decided (arbitrarily) not to compute jackknife estimates for them.

 

Result (excerpt):

                             Observed       Jackknife
parameter      Name         Statistic            Mean

 Age         Estimate       1.2783925       1.3112812
 Height      Estimate       3.5970265       3.5832738

 

Ksharp
Super User

Calling @Rick_SAS 

SteveDenham
Jade | Level 19

Number 1: See what @ballardw said about posting the log.

Number 2:  See what @FreelanceReinh  said about the syntax of PROC GLM.

Number 3: Jackknifing/resampling is a lot easier now with PROC SURVEYSELECT to generate data sets.  You can then set all of the resampled datasets with an indicator variable that you use in PROC GLM as an argument to the BY statement.  Using an OUTPUT OUT= statement, you then have all of the parameters/pvalues/other things of interest in one dataset from which you can calculate all of the jackknifed estimates.

 

SteveDenham

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

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.

Discussion stats
  • 4 replies
  • 751 views
  • 3 likes
  • 5 in conversation