Statalist


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

st: stata 10 question, different dates for each observation


From   "Tamar Brandler" <[email protected]>
To   [email protected]
Subject   st: stata 10 question, different dates for each observation
Date   Tue, 10 Nov 2009 16:49:15 -0500

I am working with Stata 10.  I have two datasets, dataset 1 has most of
the variables I want, and has one date (that I want) for each observation
(meaning each observation has one date that is not the same as the other
observations).  Dataset 2 has 2 versions of several variables coded as 0,1
that I want (lets call them A1 A 2 B1 B 2 C1 C 2 etc?).  There are
multiple dates for each observation in dataset 2 (including my date of
interest- the date that I am using for each observation in dataset1?.which
again, is a different date for each observation).  What I would like to do
is merge together the two datasets, and get rid of any data on A1 A 2 B1 B
2 C1 C 2 (etc?) that occurs after the date of interest (for each
observation), and then create one variable for A (for example) coded as 1
if A1 or A2 ever equals 1 (on my date of interest or any date before my
date of interest) (otherwise it will be 0), and create one variable B
coded as 1 if B1 or B2 ever equals 1 (on my date of interest or any date
before my date of interest)?.and so on, for all of those variables? (after
I create A, B, C etc...coded as 0,1 based on my adding together all the
A1s and A2s before and including my date of interest, I want to also get
rid of all the dates before my date of interest, because I don't need any
info from those dates except for the initial info on A1 A2 etc in order to
create my A variable- which I will just put in with the data for my date
of interest).

I am not sure what the order should be, in order to accomplish this- do I
merge first, so that I will know the date of interest? How do I get rid of
all the observations after the date of interest? How do I add up all of
the As (A1s and A2s) to get my 0 or 1 (0 is if all the A1s and A2s up to
and including my date of interest equal 0?otherwise its 1)?


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