Statalist


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

st: generate a varaible from date


From   "21443017" <[email protected]>
To   <[email protected]>
Subject   st: generate a varaible from date
Date   Tue, 4 Aug 2009 10:55:43 +0100

Dear All,

How do I generate a variable which equals 1 for the first month the company
enters the dataset, equals 2 for the second month the company enters the
dataset etc...
 
It is an unbalanced panel, so every company starts from a different date.

I have an example of the dataset below,

 
companyname	              companyid	  date	date_s	variable
Agra and Masterman's ltd	1	01-03-1965	-1138	       1
Agra and Masterman's ltd	1	01-04-1965	-1137	       2
Agra and Masterman's ltd	1	01-05-1965	-1136	       3
Agra and Masterman's ltd	1	01-06-1965	-1135	       4
Agra and Masterman's ltd	1	01-07-1965	-1134	       5
Agra and Masterman's ltd	1	01-08-1965	-1133	       6
Agra and Masterman's ltd	1	01-09-1965	-1132	       7
Agra and Masterman's ltd	1	01-10-1965	-1131	       8
Agra and United Service ltd	2	01-03-1959	-1210	       1
Agra and United Service ltd	2	01-04-1959	-1209	       2
Agra and United Service ltd	2	01-05-1959	-1208	       3
Agra and United Service ltd	2	01-06-1959	-1207	       4
Agra and United Service ltd	2	01-07-1959	-1206	       5
Agra and United Service ltd	2	01-08-1959	-1205        6
Agra and United Service ltd	2	01-09-1959	-1204	       7
Agra and United Service ltd	2	01-10-1959	-1203	       8
Agra and United Service ltd	2	01-11-1959	-1202	       9
Agra and United Service ltd	2	01-12-1959	-1201	      10
Agra,ltd a	                  3	01-04-1967	-1113	      1
Agra,ltd a	                  3	01-05-1967	-1112	      2
Agra,ltd a	                  3	01-06-1967	-1111	      3
Agra,ltd a	                  3	01-07-1967	-1110	      4
Agra,ltd(do b)	            4	01-02-1968	-1103	      1
Agra,ltd(do b)	            4	01-03-1968	-1102	      2
Agra,ltd(do b)	            4	01-04-1968	-1101	      3
Agra,ltd(do b)	            4	01-05-1968	-1100	      4
Agra,ltd(do b)	            4	01-06-1968	-1099	      5
Agra,ltd(do b)	            4	01-07-1968	-1098	      6
Agra,ltd(do b)	            4	01-08-1968	-1097	      7
Agra,ltd(do b)	            4	01-09-1968	-1096	      8
Agra,ltd(do b)	            4	01-10-1968	-1095	      9
Agra,ltd(do b)	            4	01-11-1968	-1094	     10
Albion	                  5	01-04-1965	-1137	      1
Albion	                  5	01-05-1965	-1136	      2
Albion	                  5	01-06-1965	-1135       3


?Variable? is the variable that I want to generate from the date.


Many Thanks for your help.


Best Wishes

Wenwen 



*
*   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