Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Creating a graph


From   "Scott Merryman" <[email protected]>
To   [email protected]
Subject   Re: st: Creating a graph
Date   Thu, 23 Aug 2007 11:58:49 -0500

Like this?


clear
set obs 20
gen id = _n
set seed 12345
gen byte  male = uniform() <.5
gen leave = 10000 + _n*100 if uniform() <.7
format leave %d

egen count = count(male) , by(male)
bysort male (leave): gen percent = (count-_n+1)*100/count if leave !=.
replace percent = percent[_n-1] if percent == .

gen foo = c(current_date) if leave == .
gen  foo2 = date(foo, "dmy")
format foo2 %d
replace leave = foo2 if leave  ==.
drop foo*

twoway connect per leave if male == 0 ///
|| conn per leave if male == 1  ///
||, legend(order(1 "Female" 2 "Male"))


l,sepby(male)

Scott


On 8/23/07, Richard Ohrvall <[email protected]> wrote:
> Dear Statalist,
>
> I have a problem constructing the kind of graph I would like to get. I
> have a dataset containing individuals working within an organisation.
> They have all started working there at the same time, but some have
> left the organisation. I have one variable with a unique ID, one
> variable with their sex, and finally one variable with the data of
> their departure. The final variable is a ordinary text variable in the
> format "yyyymmdd" which is equal to "" for those individuals who are
> still in the organisation.
>
> What I would like to create is a graph with one line representing the
> percentage of men still in the organisation and one line for women,
> ie. the line starts at the value 100 at the time when the organisation
> was set up, say 20021101, and ends at my final data point, say
> 20061231. The y-axis should represent percent and the x-axis time. I
> also would like to create a similar graph with absolute numbers, ie.
> the y-axis would represent the number of individuals instead of
> percent.
>
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index