Statalist The Stata Listserver


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

Re: st: extract data points from series


From   "Stas Kolenikov" <[email protected]>
To   [email protected]
Subject   Re: st: extract data points from series
Date   Mon, 26 Mar 2007 08:41:04 -0500

An easier way to generate the first month dummy is

by year: g firstmonth = whatever if _n==1

Read on -by-, you won't feel native with data manipulation until you
understand it.

Unfortunately, there is no good answer to the "best" question, as the
purpose of this plot is only known to you, so it would be up to you to
decide whether it performs the task you need. You might want to plot
annual averages instead, or the series that is somehow
filtered/smoothed.

On 3/24/07, d.cyril <[email protected]> wrote:
Hello,

I've been using Stata for some time now but still don't find myself
native when it comes to data manipulation. Wonder if you could affirm
the method I used and suggest possible extension.

Consider, you have few time-series - with var year [1970m01-2007m01]
(%tm) - and you want to plot a basic tsline (read twoway connected)
with markers. Because there are so many observations in the data set,
the plot doesn't look adequate. Since, short-term dynamics don't
matter too much I decided to take first month observation for each
year using:

-------------------------------------------
. tsset year
. gen tmp1 = string(year)
. gen tmp2 = real(tmp1)
. gen tmp3 = tmp2 if (int(tmp2/12)==tmp2/12)
. twoway (connected xxx year, msymbol(O)) if tmp3 !=.
. format tmp3 %tm
-------------------------------------------

It works alright but would it be the best way of doing it? Since it
clearly only works for the 1st month of each year, another question
begs to be answered - how would you perform the same task with
quarterly/half-year data points to increase precision?


Regards,
D.Cyril
*
*   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/


--
Stas Kolenikov
http://stas.kolenikov.name
*
*   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