Statalist


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

Re: st: if else


From   "Eva Poen" <eva.poen@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: if else
Date   Mon, 24 Mar 2008 19:13:39 +0000

Ronnie,

try

if "$member" == "jane" {
       assert memid == 10201
       }
else if "$member" == "john" {
       assert memid == 10101
       }

Note the double quotes. Without them, the line reads to Stata
- if john == "jane" -
and it complains that it can't find a variable (or scalar) named john.


Eva


2008/3/24, Ronnie Babigumira <rb.glists@gmail.com>:
> Dear Listers,
>  I have data with codes for the members who collected the data and I would like to assert that these codes are correct.
>
>  Here is what I have done
>
>  global member "john" // defined in another do-file
>
>  *** do-file that checks member codes *****
>  cd c:\temp/$member
>
>  input houscode      memid
>          1      10101
>          2      10101
>          3      10101
>  end
>
>  if $member == "jane" {
>         assert memid == 10201
>         }
>  else if $member == "john" {
>         assert memid == 10101
>         }
>  exit
>
>  When I run this code, I get an error message -john not found-. What I had hoped is that this code would take the
>  information in the $member and them check that the variable memid has the correct code
>
>  Am I missing something obvious. Please help
>
>  Ronnie
>  *
>  *   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index