2
votes

Hi I am using proc transreg in a SAS Macro.

The code listed as follows,

  %if &cnt_amt>0 %then %do;
    ods output boxcox=boxcox; 

    proc transreg data=data0; 
      where &response>0;
      model BoxCox(&response / lambda=0.05 to 1 by 0.05) = identity(&vars_amt);
      run;

    data _null_;
      set boxcox;
      if ci='<';
      call symput ('lambda',lambda);
      run;

  %end; /* %if cnt_amt>0 ... */
  %else %let lambda=0.4;

When I run the code on my work computer, the code run perfectly fine and does not give me any error message. However, when I run the code on my personal laptop, the code gives me an error message and the dataset work.boxcox is not generated.

I have been spending two weeks on this issue. Any help will be truly appreciated.

Following up,

Here is the log when the code is running perfectly on my work computer,the dataset boxcox is generated

MPRINT(MIXTRAN):   ods exclude all ;
MPRINT(MIXTRAN):   ;
MPRINT(MIXTRAN):   ** ods exclude all ;
MPRINT(MIXTRAN):   ods exclude all ;
MPRINT(MIXTRAN):   ;
MPRINT(MIXTRAN):   ** ods exclude all ;
SYMBOLGEN:  Macro variable TITLES resolves to 4
MPRINT(MIXTRAN):   title5 "Starting Estimates for Amount Model" ;
SYMBOLGEN:  Macro variable LAMBDA resolves to
MLOGIC(MIXTRAN):  %IF condition &lambda eq  is TRUE
SYMBOLGEN:  Macro variable CNT_AMT resolves to 2
MLOGIC(MIXTRAN):  %IF condition &cnt_amt>0 is TRUE
MPRINT(MIXTRAN):   ods output boxcox=boxcox;
NOTE: There were 872 observations read from the data set WORK._PERSONS.
NOTE: The data set WORK._PERSONS has 872 observations and 8 variables.
NOTE: PROCEDURE SORT used (Total process time):
  real time           0.04 seconds
  cpu time            0.03 seconds


MPRINT(MIXTRAN):   proc transreg data=data0;
SYMBOLGEN:  Macro variable RESPONSE resolves to totaldfe
MPRINT(MIXTRAN):   where totaldfe>0;
SYMBOLGEN:  Macro variable RESPONSE resolves to totaldfe
SYMBOLGEN:  Macro variable VARS_AMT resolves to WEEKEND SEQORDER
MPRINT(MIXTRAN):   model BoxCox(totaldfe / lambda=0.05 to 1 by 0.05) =     identity(WEEKEND
SEQORDER);
MPRINT(MIXTRAN):   run;

**NOTE: The data set WORK.BOXCOX has 20 observations and 7 variables.**
NOTE: There were 936 observations read from the data set WORK.DATA0.
  WHERE totaldfe>0;
NOTE: PROCEDURE TRANSREG used (Total process time):
  real time           0.08 seconds
  cpu time            0.04 seconds

Here is the log when the code is not running well on my laptop. The dataset boxcox is not generated

MPRINT(MIXTRAN):   ** ods exclude all ;
SYMBOLGEN:  Macro variable TITLES resolves to 4
MPRINT(MIXTRAN):   title5 "Starting Estimates for Amount Model" ;
SYMBOLGEN:  Macro variable LAMBDA resolves to
MLOGIC(MIXTRAN):  %IF condition &lambda eq  is TRUE
SYMBOLGEN:  Macro variable CNT_AMT resolves to 2
MLOGIC(MIXTRAN):  %IF condition &cnt_amt>0 is TRUE
MPRINT(MIXTRAN):   ods output boxcox=boxcox;
NOTE: There were 872 observations read from the data set WORK._PERSONS.
NOTE: The data set WORK._PERSONS has 872 observations and 8 variables.
NOTE: PROCEDURE SORT used (Total process time):
  real time           0.03 seconds
  cpu time            0.03 seconds


MPRINT(MIXTRAN):   proc transreg data=data0;
SYMBOLGEN:  Macro variable RESPONSE resolves to totaldfe
MPRINT(MIXTRAN):   where totaldfe>0;
SYMBOLGEN:  Macro variable RESPONSE resolves to totaldfe
SYMBOLGEN:  Macro variable VARS_AMT resolves to WEEKEND SEQORDER
MPRINT(MIXTRAN):   model BoxCox(totaldfe / lambda=0.05 to 1 by 0.05) =     identity(WEEKEND SEQORDER);
MPRINT(MIXTRAN):   run;

NOTE: There were 936 observations read from the data set WORK.DATA0.
  WHERE totaldfe>0;
NOTE: PROCEDURE TRANSREG used (Total process time):
  real time           0.10 seconds
  cpu time            0.03 seconds

** The dataset boxcox is not generated **

Thank you!

1
If the code runs fine on one computer it's probably an environment issue. You need to provide operating systems (windows/linux), SAS versions, etc. Also the error message is important. - stallingOne
Thanks to @DomPazz for your help! I added my log. On work computer, the dataset boxcox is generated; on my personal computer, the dataset boxcox is not generated. Thank you! - HQ L
That's weird. Are you running the same version of SAS on both machines? When you run on your machine, do you get printed output that includes the BoxCox output? - DomPazz
@DomPazz Yes. I run the same version of SAS (SAS 9.4). Is that something like I did not set up my directory/registry correct? - HQ L
It is probably an ODS setting. Do you see the BoxCox output in the listing or HTML on both machines? This is a good question for SAS Tech Support. support.sas.com Give them a call and they can walk through this with you. - DomPazz

1 Answers

1
votes

This error happens due to ODS setting. proc transreg can generate both plot and data. Because I want to save the data generated by proc transreg, I must turn the ODS graphics off.

Using one line ods graphics off; before the macro (or changing the setting of ODS registry).

The problem is gone.

Thanks everyone for replying.