Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Generating patterns from longitudinal data
From
Scott Smith <[email protected]>
To
[email protected]
Subject
st: Generating patterns from longitudinal data
Date
Thu, 21 Jul 2011 15:58:01 -0400
Hello,
I am wondering if there is an efficient method of creating and
tabulating patterns from longitudinal data. For example, I have four
waves of data with a dichotomous variable. I want to create a new
variable that will have each pattern and a count of that pattern.
There are 16 possible patterns. Instead of doing this:
gen var1=.
replace var1=0000 if time1==0 & time2==0 & time3==0 & time4==0
replace var1=1111 if time1==1 & time2==1 & time3==1 & time4==1
and doing that for the remaining 14 patterns (e.g., 0001, 0011, 0111,
1010, 0101, etc), is there way of telling stata to do this and store
it in a new variable? Otherwise, I have to manually do it, and it
takes a lot of time when I start adding demographics (because I have
to repeat the code for each level of the demographic variable).
It should look like this when I tab var1 (except for all the patterns):
var1 freq.
0000 1,000
1111 1,050
0001 850
I am using stata version 11.2.
Thank you,
Scott
*
* 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/