Variables SAS中虚拟变量的PROC平均值
我在SAS中创建了一个虚拟变量,如果两个国家都是欧洲货币联盟成员国,则在任何给定年份取1,否则在该年份取0Variables SAS中虚拟变量的PROC平均值,variables,sas,mean,proc,Variables,Sas,Mean,Proc,我在SAS中创建了一个虚拟变量,如果两个国家都是欧洲货币联盟成员国,则在任何给定年份取1,否则在该年份取0 emu1=0; if country1 in ("AUT","BEL","FIN","FRA","DEU","IRL","ITA","NLD","PRT","ESP") and year>1998 then emu1=1; if country1 in ("GRC") and year>2000 then emu1=1; emu2=0; if country2 in ("AUT
emu1=0;
if country1 in ("AUT","BEL","FIN","FRA","DEU","IRL","ITA","NLD","PRT","ESP") and year>1998 then emu1=1;
if country1 in ("GRC") and year>2000 then emu1=1;
emu2=0;
if country2 in ("AUT","BEL","FIN","FRA","DEU","IRL","ITA","NLD","PRT","ESP") and year>1998 then emu2=1;
if country2 in ("GRC") and year>2000 then emu2=1;
emu=0;
if emu1=1 and emu2=1 then emu=1;
现在我想分别查看取值emu=0的国家和取值emu=1的国家的变量gdp1
的平均值。我该怎么做
我知道我可以使用PROC方法:
PROC MEANS DATA=gravitydata mean MAXDEC=2;
VAR gdp1;
run;
但这显示了所有观察的平均值
提前感谢。只需添加一个class
语句,即可按指定变量分组
PROC MEANS DATA=gravitydata mean MAXDEC=2;
CLASS emu;
VAR gdp1;
run;
我试过了,但我发现了以下错误:507proc意味着DATA=gravitydata意味着MAXDEC=2;508级动车组;错误:找不到变量EMU。509var-gdp1;510跑代码>当您创建EMU变量时,您将数据集称为什么?啊,谢谢。我忘记了更改数据。现在很好用。谢谢!即使没有看到Keith的代码,也能进行惊人的调试:)