Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: count differents values of a variable


From   "Pablo.CARVALLO" <pablocepal@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: count differents values of a variable
Date   Wed, 13 Jul 2011 14:42:27 -0400

Dear List,

I have the following dataset:

quarter    country    var1
1996q2    arg        D
1996q3    arg        D
1996q4    arg        D
1997q1    arg        A
1997q2    arg        A
1997q3    arg        A
1997q4    arg        A
1998q1    arg        D
1998q2    arg        A
2002q4    arg        A
2003q1    arg        D
2003q2    arg        D
2003q3    arg        D
2003q4    arg        D
2004q1    arg        A
2004q2    arg        D

I need a new variable to know when a new value of var1 starts and how
many quarters this value repeats.

For example, there are 3 "D" from 1996q2-1996q4, so that newvar=3.


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index