Kenzie De Keyser
Kenzie De Keyser

Reputation: 5

Is there a way to make a dummy variable in SAS for a Country in my SAS Data Set?

I am looking to create a dummy variable for Latin American Countries in my data set which I need to make for a log-log model. I know how to log all of them for my later regression. Any suggestion or help on how to make a dummy variable for the Latin American countries with my data would be appreciated.

data HW6;
input country : $25. midyear sancts lprots lfrac ineql pop;
cards;
CHILE  1955 58 44 65 57 6.743
CHILE  1960 19 34 65 57 7.785
CHILE  1965 27 24 65 57 8.510
CHILE  1970 36 29 65 57 9.369
CHILE  1975 38 58 65 57 10.214
COSTA_RICA 1955 16 7 54 60 1.024
COSTA_RICA 1960 6 1 54 60 1.236
COSTA_RICA 1965 2 1 54 60 1.482
COSTA_RICA 1970 3 1 54 60 1.732
COSTA_RICA 1975 2 3 54 60 1.965
INDIA  1955 81 134  47 52 404.478
INDIA  1960 101 190 47 52 445.857
INDIA  1965 189 845 47 52 494.882
INDIA  1970 133 915 47 52 553.619
INDIA  1975 132 127 47 52 616.551
JAMICA 1955 11 12 47 62 1.542
JAMICA 1960  9  2 47 62 1.629
JAMICA 1965  8  6 47 62 1.749
JAMICA 1970  1  1 47 62  1.877
JAMICA 1975  7  1 47 62  2.043
PHILIPPINES 1955 26 123 48 56 24.0
PHILIPPINES 1960 20  38 48 56 27.898
PHILIPPINES 1965 9   5  48 56 32.415
PHILIPPINES 1970 79  25 48 56 37.540
SRI_LANKA 1955 29 2 73 52 8.679
SRI_LANKA 1960 75 35 73 52 9.879
SRI_LANKA 1965 25 63 73 52 11.202
SRI_LANKA 1970 34 14 73 52 12.532
TURKEY 1955 79  1  67 61 24.145
TURKEY 1960 138 19 67 61 28.217
TURKEY 1965  36 51 67 61 31.951
TURKEY 1970  51 22 67 61 35.743
URUGUAY 1955 8  4  57 48 2.372
URUGUAY 1960 12 1  57 48 2.538
URUGUAY 1965 16 14 57 48 2.693
URUGUAY 1970 21 19 57 48 2.808
URUGUAY 1975 24 45 57 48 2.829
VENEZUELA 1955 38  14  76 65 6.110
VENEZUELA 1960 209 23  76 65 7.632
VENEZUELA 1965 100 162 76 65 9.119
VENEZUELA 1970 9   27  76 65 10.709
VENEZUELA 1975 4   12  76 65 12.722
; 
data newData;
    set HW6;
    sancts = log (sancts);
    lprots = log (lprots);
    lfrac  = log (lfrac);
    ineql  = log (ineql);
    pop    = log (pop);
run;

Upvotes: 0

Views: 98

Answers (2)

Kermit
Kermit

Reputation: 3117

The GLMSELECT procedure is one simple way of creating dummy variables.
There is a nice article about how to use it to generate dummy variables

data newData;
    set HW6;
    sancts = log (sancts);
    lprots = log (lprots);
    lfrac  = log (lfrac);
    ineql  = log (ineql);
    pop    = log (pop);
    Y = 0; *-- Create a fake response variable --*
run;

proc glmselect data=newData noprint outdesign(addinputvars)=want(drop=Y);
   class country; 
   model Y = country / noint selection=none;
run;

If needed in further step, use the macro-variable &_GLSMOD created by the procedure that contains the names of the dummy variables.

Upvotes: 2

Gaadek
Gaadek

Reputation: 159

The real question here is not related to SAS, it is related on how to get the region of a country by its name.

I would give a try to the ISO 3166 which lists all countries and their geographical location.

Getting that list is straight forward, then import that list in SAS, use a merge by country and finally identify the countries in Latin America

Upvotes: 0

Related Questions