Statalist


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

Re: st: Creating a graph


From   "Svend Juul" <SJ@SOCI.AU.DK>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Creating a graph
Date   Thu, 23 Aug 2007 19:45:01 +0200

Richard wrote:
 
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.
 
-------------------------------------------------------
 
This looks like a typical survival analysis to me. Look at -stset- 
and -sts graph-. Those still in the organization should be handled as
censored at the last day of observation.
 
Before proceeding, you need to convert your string dates to numeric dates.
If you use Stata 10, it is pretty straightforward (sdate1 being the string
date, date1 the numeric date):
 
   generate date1 = date(sdate1,"YMD")
   format date1 %td
 
Prior to Stata 10 you might benefit from the unofficial -todate- command:
 
   findit todate
 
Hope this helps
Svend
 
________________________________________________________ 
 
Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6 
DK-8000 Aarhus C,  Denmark 
Phone, work:  +45 8942 6090 
Phone, home:  +45 8693 7796 
Fax:          +45 8613 1580 
E-mail:       sj@soci.au.dk 
_________________________________________________________ 

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index