BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
marymarion
Obsidian | Level 7
data conv;
input c1-c16 @@;
cards;
70 60 89 81 69 62 88 81 60 49 88 60 59 52 86 79
;

options mrecall;                                                                                                                       
%macro yates(data,kk,n,method);                                                                                                                
options MPRINT SYMBOLGEN MLOGIC ;
proc datasets; delete yates; run;

%MACRO keeper; keep %do i=0 %to &kk+1; step&i %end; %MEND; *DATA IS READ INTO c1-c&n; data yates; set &data; %keeper; *DEFINE COLUMN ARRAYS, ONE ADDITIONAL COLUMN FOR YATES STDZ EFECT IS ALLOWED FOR; array s0(*) c1-c&n; %do i=1 %to &kk+1; array s&i(&n); /* %put "Debug1 " &i &n; */ %end; *SET COLUMN ARRAYS TO ZERO s0 = input data; %do j=1 %to &n; %do i=1 %to &kk+1; s&i[&j]=0; /* %put "Debug2 " &i &j; */ %end; %end; *FILL IN KK COLUMNS USING YATES ALGORITHM; %do p = 0 %to (&kk-1) %by 1; %let q=%eval(&p+1); *fill in upper 1/2 of each column; %do i = 1 %to &n/2 %by 1; %let j=%eval(2*&i); s&q[&i] = s&p[&j-1]+s&p[&j]; *fill in lower 1/2 of each column; %let k=%eval(&n/2+&i); s&q[&k] = -s&p[&j-1]+s&p[&j]; /* %put "Debug3 " &i &j &k; */ %end; *i; %end; *p; *COMPUTE YATES STDZ EFFECT; %let q=%eval(&kk+1); %do i=1 %to &n %by 1; %if %upcase(&method)=DEJ %then %do; s&q[&i]=s&kk[&i]/sqrt(&n); %end; %if %upcase(&method)=BOX %then %do; divisor=&n; %if &i>1 %then %do; divisor=&n/2; %end; s&q[&i]=s&kk[&i]/divisor; %end; %if %upcase(&method)=MGH %then %do; divisor=&n; %if &i>1 %then %do; divisor=&n/2; %end; s&q[&i]=s&kk[&i]/divisor; %end; %if %upcase(&method)=OEH %then %do; s&q[&i]=s&kk[&i]/(2**&kk); %end; %if %upcase(&method)=HICKS %then %do; divisor=&n/2; s&q[&i]=s&kk[&i]/divisor; %end; *final column = coefficient in ANOVA; /* %put "Debug4 " &i &q; */ %end; *OUTPUT RESULTS; %do j = 1 %to &n; %do i = 0 %to &kk+1 %by 1; step&i=s&i[&j]; %put step&i s&i[&j]; %end; output; %end; run; title "YATES ANALYSIS USING &method Method and dataset &data"; options ls=120; proc print data=yates; run; quit; title; options ls=79; %mend yates; %yates(conv,4,16,DEJ);
1 ACCEPTED SOLUTION

Accepted Solutions
marymarion
Obsidian | Level 7

It was the comment statements.  They are different in SAS macro code. Thank you.  Mary Marion 

 

%macro yates(data,kk,n,method);                                                                                                                
options mrecall;

/*
YATES ALGORITHM TO COMPUTE EFFECTS
data = input data set which can not have the name of yates.
see example at end for read in.
kk = power of 2 = number of steps in the Yates Computations
n = length of data array = 2^kk

Only DEJ method is giving standardized effects. The other methods
produce results that can help identify significant effects in a half normal plot,
but they would not allow you to estimate sigma when you re-plot after removing
the significant effects. Only DEJ method allows that.
*/

options MPRINT SYMBOLGEN MLOGIC ;
proc delete data=yates; run; quit;

%MACRO keeper;
keep %do i=0 %to &kk+1; step&i %end;
%MEND;

/* DATA IS READ INTO c1-c&n */
data yates; set &data;
%keeper;

/* DEFINE COLUMN ARRAYS, ONE ADDITIONAL COLUMN FOR YATES STDZ EFFECT IS ALLOWED FOR */
array s0(*) c1-c&n;
%do i=1 %to &kk+1;
array s&i(&n);
/* %put "Debug1 " &i &n; */
%end;

/* SET COLUMN ARRAYS TO ZERO s0 = input data */
%do j=1 %to &n;
%do i=1 %to &kk+1;
s&i[&j]=0;
/* %put "Debug2 " &i &j; */
%end;
%end;

/* FILL IN KK COLUMNS USING YATES ALGORITHM */
%do p = 0 %to (&kk-1) %by 1;
%let q=%eval(&p+1);
*fill in upper 1/2 of each column;
%do i = 1 %to &n/2 %by 1;
%let j=%eval(2*&i);
s&q[&i] = s&p[&j-1]+s&p[&j];
*fill in lower 1/2 of each column;
%let k=%eval(&n/2+&i);
s&q[&k] = -s&p[&j-1]+s&p[&j];
/* %put "Debug3 " &i &j &k; */
%end; *i;
%end; *p;

/* COMPUTE YATES STDZ EFFECT
METHOD DIVISOR
********************************************************
DEJ sqrt(n) for each effect
BOX n for first effect, n/2 for all other effects
MGH n for first effect, n/2 for all other effects
OEH n for all effects
HICKS n/2 for all effects
*********************************************************
*/

%let q=%eval(&kk+1);
%do i=1 %to &n %by 1;

divisor=sqrt(&n);
%if %upcase(&method)=DEJ %then %do;
s&q[&i]=s&kk[&i]/divisor; %end;

divisor=&n;
%if %upcase(&method)=BOX %then %do;
s&q[&i]=s&kk[&i]/divisor; %end;
%if &i>1 %then %do;
divisor=&n/2;
s&q[&i]=s&kk[&i]/divisor; %end;

divisor=(2**&kk);
%if %upcase(&method)=OEH %then %do;
s&q[&i]=s&kk[&i]/divisor; %end;

divisor=&n/2;
%if %upcase(&method)=HICKS %then %do;
s&q[&i]=s&kk[&i]/divisor; %end;

%if %upcase(&method)=MGH %then %do;
divisor=&n/2;
s&q[&i]=s&kk[&i]/divisor; %end;
%if &i>1 %then %do;
divisor=&n/2;
%end;

/* final column = coefficient in ANOVA */
/* %put "Debug4 " &i &q; */
%end;

*OUTPUT RESULTS;
%do j = 1 %to &n;
%do i = 0 %to &kk+1 %by 1;
step&i=s&i[&j];
%put step&i s&i[&j];
%end;
output;
%end;
run;

title "YATES ANALYSIS USING &method Method and dataset &data";
options ls=120;
proc print data=yates;
run; quit; title;
options ls=79;
%mend yates;

 

View solution in original post

5 REPLIES 5
Tom
Super User Tom
Super User

What is the actual question.

Which PRINT are you talking about?

What is "extra output"?

 

Are you asking about the OBS= dataset option?

 

marymarion
Obsidian | Level 7

I just mentioned nofs because I saw something about it online.

The print I am talking about is as follows:

 

title "YATES ANALYSIS USING &method Method and dataset &data";
options ls=120;
proc print; run; quit; title;
options ls=79;
%mend yates2;

 

See attached file for extra output.

 

 

 

The extra output is: (how can I stop this?)

 

 

Directory

Libref

WORK

Engine

V9

Physical Name

/saswork/SAS_work526D00009A9A_odaws02-usw2-2.oda.sas.com/SAS_work24D000009A9A_odaws02-usw2-2.oda.sas.com

Filename

/saswork/SAS_work526D00009A9A_odaws02-usw2-2.oda.sas.com/SAS_work24D000009A9A_odaws02-usw2-2.oda.sas.com

lnode Number

1811942765

Access Permission

rwx------

Owner Name

u63727585

File Size

4KB

File Size (bytes)

4096

#

Name

Member Type

File Size

Last Modified

1

CONV

DATA

256KB

02/23/2024 21 :37:07

2

REGSTRY

ITEMSTOR

32KB

02/23/2024 21 :34: 15

3

SASGOPT

CATALOG

12KB

02/23/2024 21 :34: 15

4

SASMAC1

CATALOG

224KB

02/23/2024 21 :54:13

5

SASMAC2

CATALOG

20KB

02/23/2024 21 :34:15

6

SASMAC3

CATALOG

20KB

02/23/2024 21 :34:15

7

SASMAC4

CATALOG

20KB

02/23/2024 21 :54:13

8

SASMAC5

CATALOG

20KB

02/23/2024 21 :34:15

9

SASMAC6

CATALOG

20KB

02/23/2024 21 :34:15

10

SASMAC7

CATALOG

20KB

02/23/2024 21:34:15

11

SASMAC8

CATALOG

20KB

02/23/2024 21 :34:15

12

SASMAC9

CATALOG

20KB

02/23/2024 21 :34:15

13

SASMACR

CATALOG

20KB

02/23/2024 21 :53:59

14

YATES

DATA

256KB

02/23/2024 21 :43:24

 

Expected output is:

YATES ANALYSIS USING DEJ Method and dataset conv

Obs

step0

step1

step2

step3

step4

step5

1

70

130

300

600

1156

289.00

2

60

170

300

556

-64

-8.00

3

89

131

279

-32

192

24.00

4

81

169

277

-32

8

1.00

5

69

109

-18

78

-2

-0.25

6

62

170

.14

114

6

0.75

7

88

112

-17

2

-10

-1.25

8

81

165

-15

6

-6

-0.75

9

60

-10

40

0

-44

-5.50

10

49

-8

38

-2

0

0.00

11

88

.7

61

4

36

4.50

12

82

.7

53

2

4

0.50

13

60

.11

2

-2

-2

-0.25

14

52

-6

0

-8

-2

-0.25

15

86

-8

5

-2

-6

-0.75

16

79

.7

1

-4

-2

-0.25

 

 

Tom
Super User Tom
Super User

That is not from the PRINT. 

That is from some early step.

Probably from using PROC DATASETS.

Use the right tool for the job instead.

proc delete data=yates; run;

PROC DELETE will run much faster than PROC DATASETS (since it isn't trying to do anything else).

 

If you really need to use PROC DATASETS then add the NOLIST option do suppress the noise it spams you with.

proc datasets nolist lib=work; delete yates; run;

 

marymarion
Obsidian | Level 7

it is something else. Maybe some other statement is causing the problem?

 

Mary Marion

 

%macro yates(data,kk,n,method);                                                                                                                
options mrecall;  
/*                                                                                                              
   YATES ALGORITHM TO COMPUTE EFFECTS        
   data = input data set which can not have the name of yates. 
   see example at end for read in.                                                                              
   kk = power of 2 = number of steps in the Yates Computations                                                                          
   n = length of data array = 2^kk  

   Only DEJ method is giving standardized effects.  The other methods
   produce results that can help identify significant effects in a half normal plot,
   but they would not allow you to estimate sigma when you re-plot after removing 
   the significant effects.  Only DEJ method allows that. 
  
   DEJ    Dallas E. Johnson       Analysis of Messy Data Volume 2: Nonreplicated Experiments
   MGH    Mason, Gunst and Hess   Statistical Design and Analysis of Experiments, page 131
   BOX    Box,Hunter and Hunter   Statistics for Experimenters, page 322
   OEH    Oehlert                 A First Course in Design and Analysis of Experiments (2000)                 
   HICKS  Hicks and Turner        Fundamental Concepts in the Design of Experiments, page 349
   
*/ 
                                                                                                                                                        
options MPRINT SYMBOLGEN MLOGIC ;
proc delete data=yates; run; quit;

%MACRO keeper;                                                                                                                          
keep %do i=0 %to &kk+1; step&i %end;                                                                                                    
%MEND;                                                                                                                                  
                                                                                                                                        
*DATA IS READ INTO c1-c&n;                                                                                                              
data yates; set &data;                                                                                                                  
%keeper;                                                                                                                                
                                                                                                                                        
*DEFINE COLUMN ARRAYS, ONE ADDITIONAL COLUMN FOR YATES STDZ EFECT IS ALLOWED FOR;                                                      
array s0(*) c1-c&n;                                                                                                                    
%do i=1 %to &kk+1;                                                                                                                      
array s&i(&n);                                                                                                                          
/* %put "Debug1 " &i &n; */                                                                                                  
%end;                                                                                                                                  
                                                                                                                                        
*SET COLUMN ARRAYS TO ZERO s0 = input data;                                                                                            
%do j=1 %to &n;                                                                                                                        
%do i=1 %to &kk+1;                                                                                                                      
s&i[&j]=0;                                                                                                                              
/* %put "Debug2 " &i &j; */                                                                                                
%end;                                                                                                                                  
%end;                                                                                                                                  
                                                                                                                                        
*FILL IN KK COLUMNS USING YATES ALGORITHM;                                                                                              
%do p = 0 %to (&kk-1) %by 1;                                                                                                            
%let q=%eval(&p+1);                                                                                                                    
*fill in upper 1/2 of each column;                                                                                                      
%do i = 1 %to &n/2 %by 1;                                                                                                              
%let j=%eval(2*&i);                                                                                                                    
s&q[&i] = s&p[&j-1]+s&p[&j];                                                                                                            
*fill in lower 1/2 of each column;                                                                                                      
%let k=%eval(&n/2+&i);                                                                                                                  
s&q[&k] = -s&p[&j-1]+s&p[&j];                                                                                                          
/* %put "Debug3 " &i &j &k; */                                                                                              
%end; *i;                                                                                                                              
%end; *p;                                                                                                                              

*COMPUTE YATES STDZ EFFECT; 
/* ******************************************************
*  METHOD   DIVISOR
*********************************************************
*  DEJ      sqrt(n) for each effect
*  BOX      n for first effect, n/2 for all other effects
*  MGH      n for first effect, n/2 for all other effects
*  OEH      n for all effects 
*  HICKS    n/2 for all effects 
******************************************************* */
%let q=%eval(&kk+1); 
%do i=1 %to &n %by 1;

divisor=sqrt(&n);
%if %upcase(&method)=DEJ %then %do;
    s&q[&i]=s&kk[&i]/divisor; %end;

divisor=&n;
%if %upcase(&method)=BOX %then %do;
    s&q[&i]=s&kk[&i]/divisor; %end;
    %if &i>1 %then %do; 
    divisor=&n/2; 
    s&q[&i]=s&kk[&i]/divisor; %end;

divisor=(2**&kk);
%if %upcase(&method)=OEH %then %do;
    s&q[&i]=s&kk[&i]/divisor; %end;

divisor=&n/2;
%if %upcase(&method)=HICKS %then %do;
    s&q[&i]=s&kk[&i]/divisor; %end;	
    
%if %upcase(&method)=MGH %then %do;
    divisor=&n/2;
    s&q[&i]=s&kk[&i]/divisor; %end;
    %if &i>1 %then %do; 
    divisor=&n/2;
    %end;  
     
*final column = coefficient in ANOVA;
/* %put "Debug4 " &i &q; */  
%end;

*OUTPUT RESULTS;                                                                                                                        
%do j = 1 %to &n;                                                                                                                      
%do i = 0 %to &kk+1 %by 1;                                                                                                              
step&i=s&i[&j];                                                                                                                        
%put step&i s&i[&j];                                                                                                                    
%end;                                                                                                                                  
output;                                                                                                                                
%end;                                                                                                                                  
run;  

title "YATES ANALYSIS USING &method Method and dataset &data";
options ls=120;
proc print data=yates; 
run; quit; title; 
options ls=79;
%mend yates;    
marymarion
Obsidian | Level 7

It was the comment statements.  They are different in SAS macro code. Thank you.  Mary Marion 

 

%macro yates(data,kk,n,method);                                                                                                                
options mrecall;

/*
YATES ALGORITHM TO COMPUTE EFFECTS
data = input data set which can not have the name of yates.
see example at end for read in.
kk = power of 2 = number of steps in the Yates Computations
n = length of data array = 2^kk

Only DEJ method is giving standardized effects. The other methods
produce results that can help identify significant effects in a half normal plot,
but they would not allow you to estimate sigma when you re-plot after removing
the significant effects. Only DEJ method allows that.
*/

options MPRINT SYMBOLGEN MLOGIC ;
proc delete data=yates; run; quit;

%MACRO keeper;
keep %do i=0 %to &kk+1; step&i %end;
%MEND;

/* DATA IS READ INTO c1-c&n */
data yates; set &data;
%keeper;

/* DEFINE COLUMN ARRAYS, ONE ADDITIONAL COLUMN FOR YATES STDZ EFFECT IS ALLOWED FOR */
array s0(*) c1-c&n;
%do i=1 %to &kk+1;
array s&i(&n);
/* %put "Debug1 " &i &n; */
%end;

/* SET COLUMN ARRAYS TO ZERO s0 = input data */
%do j=1 %to &n;
%do i=1 %to &kk+1;
s&i[&j]=0;
/* %put "Debug2 " &i &j; */
%end;
%end;

/* FILL IN KK COLUMNS USING YATES ALGORITHM */
%do p = 0 %to (&kk-1) %by 1;
%let q=%eval(&p+1);
*fill in upper 1/2 of each column;
%do i = 1 %to &n/2 %by 1;
%let j=%eval(2*&i);
s&q[&i] = s&p[&j-1]+s&p[&j];
*fill in lower 1/2 of each column;
%let k=%eval(&n/2+&i);
s&q[&k] = -s&p[&j-1]+s&p[&j];
/* %put "Debug3 " &i &j &k; */
%end; *i;
%end; *p;

/* COMPUTE YATES STDZ EFFECT
METHOD DIVISOR
********************************************************
DEJ sqrt(n) for each effect
BOX n for first effect, n/2 for all other effects
MGH n for first effect, n/2 for all other effects
OEH n for all effects
HICKS n/2 for all effects
*********************************************************
*/

%let q=%eval(&kk+1);
%do i=1 %to &n %by 1;

divisor=sqrt(&n);
%if %upcase(&method)=DEJ %then %do;
s&q[&i]=s&kk[&i]/divisor; %end;

divisor=&n;
%if %upcase(&method)=BOX %then %do;
s&q[&i]=s&kk[&i]/divisor; %end;
%if &i>1 %then %do;
divisor=&n/2;
s&q[&i]=s&kk[&i]/divisor; %end;

divisor=(2**&kk);
%if %upcase(&method)=OEH %then %do;
s&q[&i]=s&kk[&i]/divisor; %end;

divisor=&n/2;
%if %upcase(&method)=HICKS %then %do;
s&q[&i]=s&kk[&i]/divisor; %end;

%if %upcase(&method)=MGH %then %do;
divisor=&n/2;
s&q[&i]=s&kk[&i]/divisor; %end;
%if &i>1 %then %do;
divisor=&n/2;
%end;

/* final column = coefficient in ANOVA */
/* %put "Debug4 " &i &q; */
%end;

*OUTPUT RESULTS;
%do j = 1 %to &n;
%do i = 0 %to &kk+1 %by 1;
step&i=s&i[&j];
%put step&i s&i[&j];
%end;
output;
%end;
run;

title "YATES ANALYSIS USING &method Method and dataset &data";
options ls=120;
proc print data=yates;
run; quit; title;
options ls=79;
%mend yates;

 

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!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 508 views
  • 0 likes
  • 2 in conversation