BookmarkSubscribeRSS Feed
lydiawawa
Lapis Lazuli | Level 10

Hi,

 

I'm trying to use the macro in this documentation (https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/382-2008.pdf)

with replicate 80 replicate weights , wt01 to wt80. The macro below only used a base weight, count:

%MACRO gMcNemar(DSIN = , /* INPUT DATASET*/
ROWV = , /* ROW VARAIBLE NAME */
COLV = , /* COLUMN VARIABLE NAME */
COUNT = ); /* CELL COUNT VARIABLE NAME OF R X R SQUARE TABLE*/
PROC FREQ DATA = &DSIN NOPRINT;
WEIGHT &COUNT;
TABLES &ROWV * &COLV /OUT = FREQ (DROP = PERCENT);
PROC SUMMARY DATA = FREQ;
CLASS &ROWV &COLV;
FREQ COUNT;
OUTPUT OUT = FREQ1 (WHERE = (_TYPE_ > 0 ));
%GLOBAL LEVEL;
PROC SQL NOPRINT;
SELECT MAX(&ROWV) INTO: LEVEL
FROM FREQ1;
QUIT;
DATA TEMP1 (DROP = &ROWV RENAME = (RC = CT) )
TEMP2 (DROP = &COLV RENAME = (RC = RT) ) TEMP3;
SET FREQ1 (DROP = _TYPE_ RENAME = (_FREQ_ = RC) );
IF &ROWV = . AND &COLV NE . THEN OUTPUT TEMP1;
IF &ROWV NE . AND &COLV = . THEN OUTPUT TEMP2;
IF &ROWV NE . AND &COLV NE . THEN OUTPUT TEMP3;
PROC SORT DATA = TEMP1;
BY &COLV;
PROC SORT DATA = TEMP3;
BY &COLV;
DATA TEMP13;
MERGE TEMP3 TEMP1;
BY &COLV;
PROC SORT DATA = TEMP2;
BY &ROWV;
PROC SORT DATA = TEMP13;
BY &ROWV;
DATA TEMP123;
MERGE TEMP13 TEMP2;
BY &ROWV;
IF &ROWV = &COLV THEN VIJ = RT + CT - 2*RC;
DIFF = &ROWV - &COLV;
IF DIFF > 0 THEN SEQ = COMPRESS(&ROWV||&COLV);
ELSE SEQ = COMPRESS(&COLV||&ROWV);
PROC SORT DATA = TEMP123;
BY SEQ;
PROC SQL NOPRINT ;
CREATE TABLE TEMP4 AS
SELECT SEQ, (-1)*SUM(RC) AS VIJ
FROM TEMP123
WHERE DIFF NE 0
GROUP BY SEQ
ORDER BY SEQ;
QUIT;
DATA TEMP4 (DROP = I);
SET TEMP4;
DO I = 1 TO 2;
OUTPUT;
END;
DATA TEMP1234 (KEEP = &ROWV &COLV VIJ);
MERGE TEMP123 TEMP4;
9Statistics and Data AnalysisSAS Global Forum 2008
BY SEQ;
IF &ROWV < &LEVEL AND &COLV < &LEVEL;
PROC SORT DATA = TEMP1234;
BY &COLV &ROWV ;
PROC SORT DATA = TEMP1 OUT = TEMP1_1(RENAME = (&COLV = &ROWV));
BY &COLV;
DATA RC;
MERGE TEMP2 TEMP1_1;
BY &ROWV;
D = RT - CT;
IF &ROWV < &LEVEL;
PROC IML;
USE TEMP1234;
READ ALL VAR{VIJ} INTO A;
X = J(&LEVEL - 1,&LEVEL - 1,0); /* CREATE A COLUMN MATRIX OF 1’S */
%DO I = 1 %TO (&LEVEL - 1);
X[,&I] = A[(&LEVEL - 1)*&I - (&LEVEL - 2) : (&LEVEL - 1)*&I, 1];
%END;
INVX = INV(X);
CLOSE TEMP1234;
USE RC;
READ ALL VAR{D} INTO DIJ;
GMN = DIJ‘ * INVX * DIJ;
DF = &LEVEL - 1;
QCHI95 = CINV(0.95,(&LEVEL - 1));
QCHI99 = CINV(0.99,(&LEVEL - 1));
PROBCHI = 1 - PROBCHI(GMN, (&LEVEL - 1));
PRINT GMN DF PROBCHI, QCHI95 QCHI99;
PROC DATASETS NOLIST KILL LIBRARY = WORK MEMTYPE = ALL;
QUIT;
%MEND;

Is there a way to insert replicate weights in the macro?

 

1 REPLY 1
lydiawawa
Lapis Lazuli | Level 10

Are there any references that shows how McNemar's test is used with replicate weights?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1 reply
  • 511 views
  • 0 likes
  • 1 in conversation