Statalist The Stata Listserver


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

st: Matching an observation to a variable name...


From   "Moore, Jesse" <[email protected]>
To   <[email protected]>
Subject   st: Matching an observation to a variable name...
Date   Tue, 3 Apr 2007 13:45:18 -0400

Hello all,
I have 60 variables called smon97-smon156 that each correspond to the
month of the year from 1986-2004 (So smon97 is jan 94 and smon156 is dec
98).  

I also have a variable mondx, that was created by taking the month of
diagnosis and converting it to match the numeric part of the
mon1-mon228.  I used the following command  for this step: gen mondx=
((yeardx-1986)*12) + (monthdx)

So far so good.  Now I would like Stata to use the mondx and refer to
the value of the corresponding smon97-smon156.  I only want to keep them
if that value=3.

I have been trying to use;
gen OK=.
forvalues i = 97/156 {
	if i==mondx & (smon`i'==3) replace OK = 1
}

Stata returns a type mismatch code.  Mondx and all the smon* variables
are numeric floats.

Any help would be greatly appreciated!

JSM

Jesse Moore, MD
General Surgery Resident
Fletcher Allen Healthcare
University of Vermont
802-847-5097


Confidentiality Notice:
This message, and any attachments, may contain information that is confidential, privileged, and/or protected from disclosure under state and federal laws that deal with the privacy and security of medical information. If you received this message in error or through inappropriate means, please reply to this message to notify the Sender that the message was received by you in error, and then permanently delete this message from all storage media, without forwarding or retaining a copy.

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