Michael Carney <[email protected]> writes,
> I have a data set of security prices over time, each price corresponding to
> a date column in the format, e.g., 8-Aug-1998. If I would like to take the
> prices for the first ten days of the month and place these prices in a
> separate column what commands should I use?
The Stata function date(<date>,<format>) converts a string date to an
integer recording the number of days 1jan1960, for example:
. display date("8-Aug-1998","dmy")
14099
The second argument, "dmy", indicates that the string is in the format
day followed month followed by year.
The Stata function day(<statadate>) returns the day of the month. For
instance,
. display day(14099)
8
Therefore, one solution to the problem is:
. gen newprice = price if day(date(origdate,"dmy"))<=10
-- Bill
[email protected]
*
* 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/