Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: data extraction by date

From   Alexander Tsai <>
Subject   st: RE: data extraction by date
Date   Tue, 02 Dec 2003 11:17:50 -0500

M Carney:

Assuming var1 is your stock return date variable, and var2 is the dummy
variable you want:

	gen byte m=month(var1)
	gen byte d=day(var1)
	gen var2=0
	replace var2=1 if m==1 & (d>=1 & d<=10)

I think that should work. More help can be found in the Stata User's


-----Original Message-----
[] On Behalf Of Michael
Sent: Tuesday, December 02, 2003 10:49 AM
Subject: st: data extraction by date

I have a series of stock returns sorted by Stata's standard date form
(that is, when 0 = 1Jan 1960). Is it possible for me to create a data
set with 1 for all dates ranging from 1 jan to 10 jan (including all
years) and zero otherwise. I've tried

.   gen var2 = var1 if doy(1/4), month(1)

but it doesn't seem to work. Any help would be appreciated immensely!!!

*   For searches and help try:

*   For searches and help try:

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