+ Reply to Thread
Results 1 to 3 of 3

Thread: PROC Means for dummy variables in SAS

  1. #1
    Points: 690, Level: 13
    Level completed: 80%, Points required for next Level: 10

    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    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.

    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.

  2. #2
    Omega Contributor
    Points: 38,303, Level: 100
    Level completed: 0%, Points required for next Level: 0
    hlsmith's Avatar
    Location
    Not Ames, IA
    Posts
    6,993
    Thanks
    397
    Thanked 1,185 Times in 1,146 Posts

    Re: PROC Means for dummy variables in SAS

    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;
    Stop cowardice, ban guns!

  3. The Following User Says Thank You to hlsmith For This Useful Post:

    JoLinda91 (03-03-2016)

  4. #3
    TS Contributor
    Points: 12,501, Level: 73
    Level completed: 13%, Points required for next Level: 349

    Posts
    951
    Thanks
    0
    Thanked 103 Times in 100 Posts

    Re: PROC Means for dummy variables in SAS


    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;
    All things are known because we want to believe in them.

  5. The Following User Says Thank You to Mean Joe For This Useful Post:

    JoLinda91 (03-03-2016)

+ Reply to Thread

           




Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts






Advertise on Talk Stats