Statalist The Stata Listserver


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

Re: st: combining two variables into one with half-yearly date format


From   Nick Winter <[email protected]>
To   [email protected]
Subject   Re: st: combining two variables into one with half-yearly date format
Date   Tue, 14 Mar 2006 09:31:41 -0500

This should do it:

generate hy = (year-1960)*2 + semester
format hy %th
list year semester hy

Seems to me your semester variable should be coded 0 for spring and 1 for fall, which is opposite what you imply below, though.

--Nick Winter


At 09:15 AM 3/14/2006, you wrote:

I have two time variables in my dataset - one for year and one for semester.
Both of these variables are numeric with Year containing four-digit year
values ranging from 1990 to 2005 and Semester is a 0 1 variable for fall
and spring.  The dataset is structured such that for each id every year has
two semesters.  I would like to combine the Year and Semester variables into
one time variable to allow me to work with the dataset as a panel.
Ultimately I hope to to tsset the dataset once I have the new variable.
How do I recode (or replace) the Year and Semester variables to create one
variable that is formated in the half-yearly date format?  As an end result
I would like to have one variable that reads 1990h1 for spring term 1990 and
1990h2 for fall term 1990, etc.

What I currently have:

ID  Year  Semester
1   1990        F
1   1990        S
2   1991        F
2   1991        S

What I would like to have:

ID  Half-Year
1      1990h1
1      1990h2
2      1991h1
2      1991h2

Thank you in advance for your help.

Jennifer Delaney

--
Jennifer Delaney
PhD candidate in Higher Education
Stanford University
[email protected]
*
*   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/
________________________________________________________
Nicholas J. G. Winter 607.255.8819 t
Assistant Professor 607.255.4530 f
Department of Government [email protected] e
Cornell University falcon.arts.cornell.edu/nw53 w
308 White Hall
Ithaca, NY 14853-4601

*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index