Error in macro for selecting matched controls

Reply
Learner
Posts: 1

Error in macro for selecting matched controls

[ Edited ]

I am trying to use the macro by Mounib et al in SAS paper #230-25, for matching controls to cases, and keep getting the following error:

WARNING: Variable CASE_SEX not appended because of type mismatch.

ERROR: No appending done because of anomalies listed above.

Use FORCE option to append these files.

 

Here is the code I am using.  Any suggestions would be appreciated.

 

%LET AGERANGE = 10;

%LET RATIO = 2;

 

Data cases controls;

set update2;

where analyze=1;

if mcl23 = 1 then output cases;

else if mcl23 = 2 then output controls;

run;

proc freq noprint data=cases;

tables age*sex/out=caseout;

%macro sample(V_age,V_sex,V_count);

data qualify1;

set controls;

where(&V_AGE-&AGERANGE<=AGE<=&V_AGE+&AGERANGE) AND (SEX=&V_SEX);

CASE_AGE=&V_AGE;

CASE_SEX=&V_SEX;

SEED=RANUNI(0);

PROC SORT; BY SEED;

DATA QUALIFY2;

SET QUALIFY1 NOBS=TOTOBS;

IF _N_<=&V_COUNT*&RATIO;

IF &V_COUNT*&RATIO<=TOTOBS THEN TAG ='Yes';

ELSE TAG ='NO';

PROC APPEND BASE=MATCHES DATA=QUALIFY2;

PROC SORT DATA=QUALIFY2 OUT=TEMP1 (KEEP=id); BY id;

PROC SORT DATA=CONTROLS OUT=TEMP2; BY id;

DATA CONTROLS;

MERGE TEMP1(IN=IN1) TEMP2(IN=IN2);

BY id; IF IN2 AND NOT IN1;

%MEND SAMPLE;

DATA _NULL_; SET CASEOUT;

CALL EXECUTE ('%SAMPLE('||AGE||','||SEX||','||COUNT||')');

RUN;

 

Grand Advisor
Posts: 10,196

Re: Error in macro for selecting matched controls

The error message means that the variable CASE_SEX is character in one data set and numeric in another. You need to compare you data set MATCHES and UPDATE2 for the characteristics of the variables CASE_SEX and Sex and ensure that you are appending apples to apples...

Ask a Question
Discussion stats
  • 1 reply
  • 157 views
  • 0 likes
  • 2 in conversation