Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: using another variable as a label


From   "Newson, Roger B" <[email protected]>
To   <[email protected]>
Subject   st: RE: using another variable as a label
Date   Wed, 28 Jan 2009 12:15:54 -0000

You don't say whether ymonth is numeric, and equal to the first day of
the month, and date-formatted. However, if it is, and if you wanted the
ymonth values to be evenly spaced on the graph, then you might use
-sdecode- to convert -ymonth- to string, and then use -sencode- to
convert it back to evenly-spaced integers, ordered by -order- and
labelled as for -ymonth-. Both -sencode- and -sdecode- can be downloaded
from SSC using the -ssc- command. They are "super" versions of the
official Stata commands -encode- and -decode-, respectively.

The program might read:

sdecode ymonth, gene(ymonth2)
sencode ymonth2, replace gsort(order)

The -sdecode- command creates a new string variable -ymonth2-,
containing formatted values of -ymonth-. The -sencode- command converts
-ymonth2- to a numeric variable, with evenly-spaced values ordered as
for -order-, and labels containing the appropriate formatted value of
-ymonth-.

I hope this helps.

Best wishes

Roger


Roger B Newson BSc MSc DPhil
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton Campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
UNITED KINGDOM
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: [email protected] 
Web page: http://www.imperial.ac.uk/nhli/r.newson/
Departmental Web page:
http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/pop
genetics/reph/

Opinions expressed are those of the author, not of the institution.

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Ashim Kapoor
Sent: 28 January 2009 10:37
To: [email protected]
Subject: st: using another variable as a label

Dear all,

I have a question. My dataset is like this.

Matchscore   order             ymonth
200                 1                 1990m1
280                 2                 1990m1
290                 3                 1995m7
300                 4                 2000m3
251                 5                 2000m4

This is just a small part of the dataset, but it kind of gives the
message that ymonths are not evenly spaced and can be repeated ( this
is the reason I would not graph this by ymonth). So I want to graph
this by order but I want the corresponding values of ymonth displayed.

I want to do  something like : -
twoway ( line matchscore order )  , xlabel ( using ymonth in place of
order for the xlabel )

There is a clumsy way of pulling out the order values and ymonth
values and making a numlist but I was hoping there is something better
than this because I have to automate this process.

Thank you,
Ashim
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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