Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: coding


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: coding
Date   Fri, 27 Jan 2006 20:16:37 -0500

I'm not sure I understand, but if you want to create a single categorical variable for each case based on 8 years of data and you have a categorical variable that takes on one of three possible values (possibility=1,2,3) for each year (year= 1,2,3,4,5,6,7,8), then you could::

gen score=possibility*10^(year-1)
collapse (sum) score, by(caseid)

This will give you an 8 digit number (score) for each caseid with each digit representing the value of possibility for each year. One advatage of this approach is that the resulting number can be directly interpreted. If you had more years than you might need to create the score variable as a double.

Michael Blasnik
michael.blasnik@verizon.net

----- Original Message ----- From: "Alexander Nervedi" <alexnerdy@hotmail.com>
To: <statalist@hsphsun2.harvard.edu>
Sent: Friday, January 27, 2006 7:30 PM
Subject: st: coding



Hi List users,

I am having a tough time getting my head around this.

I have data on households which goes for 8 years and in each year i can observe 3 possibilities. Thus a total of 8^3 possible histories exist.

How would I go about creating a variable that classifies the data into each of these possibilities?

I have 800 households that I need to classify in this form.

thanks!

Al
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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