我有10年的数据,需要计算其中variable =的数量。和其中变量的数量= 1的一些变量。每年都有一些共同的变数和一些不同的变量。以下代码在处有问题,其中声明。 这里是错误信息,在此先感谢您的帮助。宏变量在哪里陈述
* ERROR 22-322:语法错误,需要下列之一:名称,引用字符串,数字常量,日期时间常数, 缺失值,(,,+, - ,ALL ,ANY,BTRIM,计算CASE,INPUT,PUT,选择,一些子串,翻译, USER
这里是所有数据集:
Year N_community
2000 15339
2001 15246
2002 15142
2003 14916
2004 14500
2005 14701
2006 14732
2007 14804
2008 13651
2009 13751
下面是代码:
/* For year 2000 to 2009 and the number of "missing" */
data health_status_vars_missing;
set all;
run;
%let CmList = D_CFAIL D_CHD D_CHOLES D_DEPRSS D_HBP D_MYOCAR D_OTHHRT D_PSYCHO;
%let CmCnt = %sysfunc(countw(&CmList));
%macro countm(yr);
%do i=0 %to &yr.;
%do L=1 %to &CmCnt.;
proc sql;
create table %scan(&Cmlist., &L.)_M as
select 200&i as year, count(*) as %scan(&Cmlist., &L.)_M
from cohort0&i.
where %scan(&Cmlist., &L.)=.;
quit;
data health_status_vars_missing;
merge health_status_vars_missing(in=a) %scan(&Cmlist., &L.)_M(in=b);
by year;
if a;
run;
%end;
%end;
%mend countm;
%countm(9);
pleast使用选项MPRINT阀芯得到完整的错误消息。 – Shuguang