Dear all
I have a dataset that looks like:
FirmID rdq fqenddt earnings
12994 8/31/1987 6/30/1987
12994 11/25/1987 9/30/1987
12994 3/11/1988 12/31/1987
12994 5/25/1988 3/31/1988
12994 8/29/1989 6/30/1989
12994 11/3/1989 9/30/1989
12994 2/20/1990 12/31/1989
12994 5/10/1990 3/31/1990
12994 8/28/1990 6/30/1990
12994 12/10/1990 9/30/1990
12994 2/5/1991 12/31/1990
12994 5/3/1991 3/31/1991
12994 8/27/1991 6/30/1991
12994 11/6/1991 9/30/1991
12994 2/12/1992 12/31/1991
11907 4/28/1993 2/28/1993
11907 6/9/1993 5/31/1993
11907 9/21/1993 8/31/1993
11907 12/13/1993 11/30/1993
I focus on fqenddt (fiscal quarter end date) to construct my data as the main date variable. I want to convert this string variable to a date format and then create a quarter variable that contains the quarter number (1,2,3,or 4). One of the complications is that fiscal quarter is not always 31 March, 30June, 30 September and 31 December for all firms (for example firmID 11907 above), and also my data may have only fewer than 4 quarters available for few firms(for example firmID 12994 above)
I want to have something similar to:
FirmID rdq fqenddt year quarter earnings
1987 1
1987 2
1987 3
1987 4
1988 1
1988 2
and so on
What I have done is:
gen newdate = subinstr(fqenddt, "/", "-", .)
generate fiscalQdate = date(newstrvar, "MDY")
format %td fiscalQdate
This gave me:
fiscalQdate
30jun1987
30sep1987
31dec1987
31mar1988
30jun1989
30sep1989
31dec1989
31mar1990
My main problem is how to generate the quarter variable when few firms do not have all quarters?
Can anyone help please ?
Thanks a lot
I have a dataset that looks like:
FirmID rdq fqenddt earnings
12994 8/31/1987 6/30/1987
12994 11/25/1987 9/30/1987
12994 3/11/1988 12/31/1987
12994 5/25/1988 3/31/1988
12994 8/29/1989 6/30/1989
12994 11/3/1989 9/30/1989
12994 2/20/1990 12/31/1989
12994 5/10/1990 3/31/1990
12994 8/28/1990 6/30/1990
12994 12/10/1990 9/30/1990
12994 2/5/1991 12/31/1990
12994 5/3/1991 3/31/1991
12994 8/27/1991 6/30/1991
12994 11/6/1991 9/30/1991
12994 2/12/1992 12/31/1991
11907 4/28/1993 2/28/1993
11907 6/9/1993 5/31/1993
11907 9/21/1993 8/31/1993
11907 12/13/1993 11/30/1993
I focus on fqenddt (fiscal quarter end date) to construct my data as the main date variable. I want to convert this string variable to a date format and then create a quarter variable that contains the quarter number (1,2,3,or 4). One of the complications is that fiscal quarter is not always 31 March, 30June, 30 September and 31 December for all firms (for example firmID 11907 above), and also my data may have only fewer than 4 quarters available for few firms(for example firmID 12994 above)
I want to have something similar to:
FirmID rdq fqenddt year quarter earnings
1987 1
1987 2
1987 3
1987 4
1988 1
1988 2
and so on
What I have done is:
gen newdate = subinstr(fqenddt, "/", "-", .)
generate fiscalQdate = date(newstrvar, "MDY")
format %td fiscalQdate
This gave me:
fiscalQdate
30jun1987
30sep1987
31dec1987
31mar1988
30jun1989
30sep1989
31dec1989
31mar1990
My main problem is how to generate the quarter variable when few firms do not have all quarters?
Can anyone help please ?
Thanks a lot
Comment