Statalist


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

st: RE: Code to generate variable indicating date that CD4 drops below 250


From   "Steichen, Thomas J." <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: Code to generate variable indicating date that CD4 drops below 250
Date   Tue, 31 Mar 2009 14:32:50 -0400

Something brute force like the following might work:

gen cd4lowdate = .
format cd4lowdate %d  /* this assumes you have formatted dates as Stata date variables */
foreach n of numlist 1(1)19 {
  replace cd4lowdate = visitdate`n' if cd4`n' < 250 & cd4lowdate == .
}

-----------------------------------
Thomas J. Steichen
[email protected]
-----------------------------------

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Polis, Chelsea B.
Sent: Tuesday, March 31, 2009 1:55 PM
To: [email protected]
Subject: st: Code to generate variable indicating date that CD4 drops below 250

Dear Statalisters,

I would like to create a variable in my dataset to indicate the date at
which a subjects CD4 counts dropped below 250.  My data is currently in
wide format, and each subject had anywhere from 1 to 19 visits.  For each
subject, I have up to 19 variables that indicate cd4 count (i.e., cd41 cd42
cd43 cd44 and so on), and up to 19 variables that indicate visit  date
(visitdate1 visitdate2 visitdate3 visitdate4 etc.).  I'd like to create a
variable to indicate the first date at which CD4 count dropped below 250,
if it ever dropped below 250.

Any suggestions on how to write such a code?

Many thanks,
Chelsea

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

CONFIDENTIALITY  NOTE:  This e-mail message, including any attachment(s), contains information that may be confidential, protected by the attorney-client or other legal privileges, and/or proprietary non-public information. If you are not an intended recipient of this message or an authorized assistant to an intended recipient, please notify the sender by replying to this message and then delete it from your system. Use, dissemination, distribution, or reproduction of this message and/or any of its attachments (if any) by unintended recipients is not authorized and may be unlawful.

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