Hi, Thank you for this. I've tried it out on a more simple dependency structure where it is all the same. "sq" stands for the section and question number on the form where the variable in question is located. "tl" is unimportant in this code, just a place holder for other data sets it will be stacked with. I've attempted to modify your code, but I'm having issues with the macros. I made a few different ones (4) for the different dependency structure: %macro checkvar18b_1 (crf18bcom=,sq=);
%if &crf18bcom=. %then %do;
sq="&sq";
variable="&crf18bcom";
issue = "Missing value for &crf18bcom";
output;
%end;
%mend;
%macro checkvar18b_2 (crf18bcom=,crf18bres=,sq=);
%if &crf18bcom=1 and &crf18bres=. %then %do;
sq="&sq";
variable="&crf18bres";
issue = "Missing value for &crf18bres";
output;
%end;
%mend;
%macro checkvar18b_3 (crf18bcom=,crf18bdate=,sq=);
%if &crf18bcom=1 and &crf18bdate=. %then %do;
sq="&sq";
variable="&crf18bdate";
issue = "Missing value for &crf18bdate";
output;
%end;
%mend;
%macro checkvar18b_4 (crf18bcom=,crf18bno=,sq=);
%if &crf18bcom=2 and &crf18bno="" %then %do;
sq="&sq";
variable="&crf18bno";
issue = "Missing value for &crf18bno";
output;
%end;
%mend;
data checkvar18b;
keep studyid visitdate visit bonevisit form sq variable issue db tl dataset;
retain studyid visitdate visit bonevisit form sq variable issue db tl dataset;
format visitdate date9.;
set crf18bx4;
format tl $10. variable $30. db $40. issue $50.;
dataset="checkvar18b";
visitdate=visitdate18b;
visit=newvisit1;
bonevisit=newbonevisit;
form="CRF18b";
tl="";
%checkvar18b_1(crf18bcom=surea,sq="1");
%checkvar18b_1(crf18bcom=screat,sq="2");
%checkvar18b_1(crf18bcom=salb,sq="3");
%checkvar18b_1(crf18bcom=spho,sq="4");
%checkvar18b_1(crf18bcom=upro,sq="5");
%checkvar18b_1(crf18bcom=umic,sq="6");
%checkvar18b_1(crf18bcom=ucrea,sq="7");
%checkvar18b_1(crf18bcom=ualb,sq="8");
%checkvar18b_1(crf18bcom=uegfr,sq="9");
%checkvar18b_1(crf18bcom=ub2micro,sq="10");
%checkvar18b_1(crf18bcom=ub2ratio,sq="11");
%checkvar18b_1(crf18bcom=completedby18b,sq="");
%checkvar18b_1(crf18bcom=completeddate18b,sq="");
%checkvar18b_2(crf18bcom=surea, crf18bres=sureares,sq="1");
%checkvar18b_2(crf18bcom=screat, crf18bres=screatres,sq="2");
%checkvar18b_2(crf18bcom=salb, crf18bres=salbres,sq="3");
%checkvar18b_2(crf18bcom=sphos, crf18bres=sphores,sq="4");
%checkvar18b_2(crf18bcom=upro, crf18bres=suprores,sq="5");
%checkvar18b_2(crf18bcom=umic, crf18bres=sumicres,sq="6");
%checkvar18b_2(crf18bcom=ucre, crf18bres=sucreres,sq="7");
%checkvar18b_2(crf18bcom=ualb, crf18bres=sualbres,sq="8");
%checkvar18b_2(crf18bcom=uegfr, crf18bres=suegfrres,sq="9");
%checkvar18b_2(crf18bcom=ub2micro, crf18bres=ub2microrres,sq="10");
%checkvar18b_2(crf18bcom=ub2ratio, crf18bres=sub2ratiores,sq="11");
%checkvar18b_3(crf18bcom=surea, crf18bdate=sureadate,sq="1");
%checkvar18b_3(crf18bcom=screat, crf18bdate=screatdate,sq="2");
%checkvar18b_3(crf18bcom=salb, crf18bdate=salbdate,sq="3");
%checkvar18b_3(crf18bcom=sphos, crf18bdate=sphodate,sq="4");
%checkvar18b_3(crf18bcom=upro, crf18bdate=suprodate,sq="5");
%checkvar18b_3(crf18bcom=umic, crf18bdate=sumicdate,sq="6");
%checkvar18b_3(crf18bcom=ucre, crf18bdate=sucredate,sq="7");
%checkvar18b_3(crf18bcom=ualb, crf18bdate=sualbdate,sq="8");
%checkvar18b_3(crf18bcom=uegfr, crf18bdate=suegfrdate,sq="9");
%checkvar18b_3(crf18bcom=ub2micro, crf18bdate=ub2microdate,sq="10");
%checkvar18b_3(crf18bcom=ub2ratio, crf18bdate=ub2ratiodate,sq="11");
%checkvar18b_4(crf18bcom=surea, crf18bno=nosurea,sq="1");
%checkvar18b_4(crf18bcom=screat, crf18bno=noscreat,sq="2");
%checkvar18b_4(crf18bcom=salb, crf18bno=nosal,sq="3");
%checkvar18b_4(crf18bcom=sphos, crf18bno=nospho,sq="4");
%checkvar18b_4(crf18bcom=upro, crf18bno=noupro,sq="5");
%checkvar18b_4(crf18bcom=umic, crf18bno=noumic,sq="6");
%checkvar18b_4(crf18bcom=ucre, crf18bno=noucre,sq="7");
%checkvar18b_4(crf18bcom=ualb, crf18bno=noualb,sq="8");
%checkvar18b_4(crf18bcom=uegfr, crf18bno=uegfrnores,sq="9");
%checkvar18b_4(crf18bcom=ub2micro, crf18bno=ub2micronores,sq="10");
%checkvar18b_4(crf18bcom=ub2ratio, crf18bno=ub2rationores,sq="11");
if missing(serum) and not missing(notserum) then do;
sq="";
variable="serum";
issue="Missing value for serum";
db="notserum=.,serum=.";
output;
end;
if missing(urine) and not missing(noturine) then do;
sq="";
variable="urine";
issue="Missing value for urine";
db="noturine=.,urine=.";
output;
end;
run; After running, I don't get any errors, but nothing was output to my dataset (contains 0 obs). I know there is missing data, but unsure as to why this macro isn't outputting it. Any suggestions?
... View more