以下是下面的宏,以及底部的示例。当我尝试运行它时,我会遇到很多错误,我认为这与我使用if-else语句的方式有关。这个例子应该返回" Gum and Other Mouth"。谢谢!
%Macro CancerSite(PrimSite, Hist);
* Site recoding: http://seer.cancer.gov/siterecode/icdo3_d01272003/ (old version since cases in years < 2010);
Histology = input(&Hist, 4.);
PrimarySite = &PrimSite;
* Oral Cavity and Pharynx;
if Histology not in (9050:9055, 9140, 9590:9992) then do;
if PrimarySite in ('C000','C001','C002','C003','C004','C005','C006','C007','C008','C009')
then CancerSite = 'Lip';
else if PrimarySite in ('C030','C031','C032','C033','C034','C035','C036','C037','C038','C039',
'C050','C051','C052','C053','C054','C055','C056','C057','C058','C059',
'C060','C061','C062','C063','C064','C065','C066','C067','C068','C069')
then CancerSite = 'Gum and Other Mouth';
else if PrimarySite in ('C110','C111','C112','C113','C114','C115','C116','C117','C118','C119')
then CancerSite = 'Nasopharynx';
else if PrimarySite in ('C090','C091','C092','C093','C094','C095','C096','C097','C098','C099')
then CancerSite = 'Tonsil';
end;
%mend;
%CancerSite('C030', 9057)
答案 0 :(得分:4)
如果按原样并且单独运行它,它将构造一堆数据步骤语句,但没有其余的数据步骤 - 您需要在数据步骤中调用宏以使其正常工作。
E.g。
data output_dataset;
set input_dataset;
%CancerSite('C030', 9057)
run;