Statalist


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

Re: st: RE: programming problem


From   Jeph Herrin <[email protected]>
To   [email protected]
Subject   Re: st: RE: programming problem
Date   Thu, 16 Aug 2007 14:16:15 -0400

Duh.

I had done this:

  forval j = 1/12 {
   	replace mycond =  `j' == month & var`j' == 1
  }

Which effectively only tests month 12, before I veered
off in another direction.




Nick Cox wrote:
> Short of a solution using -reshape-, I think
> this will suit: 
> 
> gen mycond = 0 
> forval j = 1/12 { 
> 	replace mycond = 1 if `j' == month & var`j' == 1 
> } 
> 
> where I assume that your -var*- are 1 when true. 
> 
> Nick 
> [email protected] 
> 
> Jeph Herrin
>  
>> I have observations on patient admissions over
>> a 12 month period.
>>
>> For each observation, I have 12 variables, call
>> them var1-var12, which indicate whether a certain
>> condition was met for that patient for months 1-12.
>> So, eg, it may be true for months 1-3 and 7-12.
>>
>> I also have a variable -month-, which indicates
>> the current month of the observed admission. What
>> I want to capture is whether the condition was true
>> in the month of admission.
>>
>> For instance, at first I unthinkingly tried this:
>>
>>   gen mycond = var`=month'==1
>>
>> but this of course uses the first observed value
>> of -month-, which happens to be 6, and only checks
>> -var6-.
>>
>> I eventually got there by creating lots of vars, but is
>> there a more direct solution?
>>
> 
> *
> *   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/
> 
> 

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