简体   繁体   English

SAS中虚拟变量的PROC平均值

[英]PROC Means for dummy variables in SAS

I have created a dummy variable in SAS, that in any given year takes the value 1 if both countries are members of the EMU and 0 otherwise in that year. 我在SAS中创建了一个虚拟变量,如果两个国家都是EMU的成员,则在任何给定的年份中取值为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","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;

Now I want to see the mean for the variable gdp1 for countries which takes the value emu=0 and for countries which takes the value emu=1 , respectively. 现在,我想分别查看变量gdp1的平均值,该变量gdp1emu=0的国家和取值为emu=1国家。 How do I do that? 我怎么做?

I know that I can use the PROC MEANS: 我知道我可以使用PROC MEANS:

PROC MEANS DATA=gravitydata mean MAXDEC=2;
VAR gdp1;
run;

But this shows the mean for all the observation. 但这显示了所有观察的均值。

Thanks in advance. 提前致谢。

Just add a class statement, this groups by the specified variable. 只需添加一个class语句,该语句将按指定的变量分组。

PROC MEANS DATA=gravitydata mean MAXDEC=2;
CLASS emu;
VAR gdp1;
run;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM