Solved
Contributor
Posts: 46

# How do I create a Concentration curve and associated GINI coefficient?

Hi All,

I've been tasked with creating a Concentration curve based on some socioeconomic data and health data, but it's proving to be quite tricky to even find documentation on how to set things up. I've managed to find this paper about how to do it in STATA (http://repec.sowi.unibe.ch/files/wp15/jann-2016-lorenz.pdf) , but nothing for SAS. Normally I would include a sample dataset, but to be honest I can't even figure out how the data needs to be laid out. I am pretty sure it can be done, but I am at a loss as to where to begin.

Any help would be much appreciated.

Thanks so much

Mike

Accepted Solutions
Solution
2 weeks ago
Posts: 1,254

## Re: How do I create a Concentration curve and associated GINI coefficient?

Please find below a program I wrote at home about one hour ago. :-)

``````data have;
input population income;
cards;
24113 29393
6554 33011
19225 52976
19909 59591
22448 64511
24536 67992
;

data want;
output;
do until(eof1);
set have end=eof1;
total_pop+population;
total_inc+population*income;
end;
do until(eof2);
set have end=eof2;
share_inc=population*income/total_inc;
cum_pop+population/total_pop;
cum_inc+share_inc;
g+(cum_pop+max(lag(cum_pop),0))*share_inc;
output;
end;
gini=g-1;
call symput('gini', put(gini, 5.3)); /* change format 5.3 to 11.9 for comparison */
format cum: percent9.2;
label cum_pop='Cumulative shares of population'
cum_inc='Cumulative shares of income';
keep cum:;
stop;
run;

proc sgplot data=want;
title 'Lorenz curve';
series x=cum_pop y=cum_inc / legendlabel='Lorenz curve';
series x=cum_inc y=cum_inc / legendlabel='Perfect equality line';
xaxis offsetmin=0 offsetmax=0;
yaxis offsetmin=0 offsetmax=0;
inset "Gini coeff.: &gini" / border position=left textattrs=(Size=12);
refline 0.2 to 1 by 0.2;
run;``````

It replicates the results of the "complete handout" (section "2. Age inequalities", Table 3, Graph 3) linked in section "External links" of the Wikipedia article "Lorenz curve".

Graph:

All Replies
Posts: 1,345

## Re: How do I create a Concentration curve and associated GINI coefficient?

This link https://groups.google.com/forum/#!topic/comp.soft-sys.sas/UaXlg153QpM is a Pace University revision  of a program I wrote at Univ of Penn about 25  years ago.

Contributor
Posts: 46

## Re: How do I create a Concentration curve and associated GINI coefficient?

Thanks so much for this mkeitz, I'll take a closer look at this and hopefully get a better sense of how things need to get set up.

Rightcoast.
Solution
2 weeks ago
Posts: 1,254

## Re: How do I create a Concentration curve and associated GINI coefficient?

Please find below a program I wrote at home about one hour ago. :-)

``````data have;
input population income;
cards;
24113 29393
6554 33011
19225 52976
19909 59591
22448 64511
24536 67992
;

data want;
output;
do until(eof1);
set have end=eof1;
total_pop+population;
total_inc+population*income;
end;
do until(eof2);
set have end=eof2;
share_inc=population*income/total_inc;
cum_pop+population/total_pop;
cum_inc+share_inc;
g+(cum_pop+max(lag(cum_pop),0))*share_inc;
output;
end;
gini=g-1;
call symput('gini', put(gini, 5.3)); /* change format 5.3 to 11.9 for comparison */
format cum: percent9.2;
label cum_pop='Cumulative shares of population'
cum_inc='Cumulative shares of income';
keep cum:;
stop;
run;

proc sgplot data=want;
title 'Lorenz curve';
series x=cum_pop y=cum_inc / legendlabel='Lorenz curve';
series x=cum_inc y=cum_inc / legendlabel='Perfect equality line';
xaxis offsetmin=0 offsetmax=0;
yaxis offsetmin=0 offsetmax=0;
inset "Gini coeff.: &gini" / border position=left textattrs=(Size=12);
refline 0.2 to 1 by 0.2;
run;``````

It replicates the results of the "complete handout" (section "2. Age inequalities", Table 3, Graph 3) linked in section "External links" of the Wikipedia article "Lorenz curve".

Graph:

Contributor
Posts: 46

## Re: How do I create a Concentration curve and associated GINI coefficient?

Thanks so much Freelance!

This is a huge help. It will take me a little bit to go through and figure out what you did, but that will be a good exercise all on its own. It's becoming clear to me that the "DO loop" is something I'm going to have to get more comfortable with.

Thanks again.

Mike

☑ This topic is solved.

Discussion stats
• 4 replies
• 107 views
• 0 likes
• 3 in conversation