PROC Means for dummy variables in SAS

#1
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.

Code:
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. How do I do that?

I know that I can use the PROC MEANS:

Code:
PROC MEANS DATA=gravitydata mean MAXDEC=2;
VAR gdp1;
run;
But this shows the mean for all the observation.

Thanks in advance.
 

hlsmith

Omega Contributor
#2
Does the following work? You may need to look at the log to see if you need to do a proc sort; by EMU; run; first of not.


Code:
PROC MEANS DATA=gravitydata mean MAXDEC=2;VAR gdp1;
by EMU;run;
 

Mean Joe

TS Contributor
#3
The BY statement will work when data is sorted; alternatively there is the CLASS statement, and you don't need to sort your data.

Code:
PROC MEANS DATA=gravitydata mean MAXDEC=2;
CLASS emu; *just add this;
VAR gdp1;
run;