Statalist


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

st: RE: if not iffing in ado


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: if not iffing in ado
Date   Thu, 9 Oct 2008 10:16:03 +0200

Your -syntax- appears to take the -if- qualifier, but then nothing happens,
because you let swapval go about its work without regard to the -if-
qualifier. Normal practice would probably be to use -marksample touse- and
then to -if `touse'-...


HTH
Martin

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Paul O'Brien
Sent: Thursday, October 09, 2008 10:01 AM
To: statalist
Subject: st: if not iffing in ado

i have a small program to temporarily swap variables using swapval.  
but i cannot get the 'if' to work.

program swap
// used to swap treatment and control (iud r and se)
version 10
syntax [if]
swapval iud1 iud2
swapval r1 r2
swapval se1 se2
...
end

. local s=1
. swap if `s' ==1
(79 missing values generated)
(84 missing values generated)

. list r1 r2 in 1

      +----------+
      |  r1   r2 |
      |----------|
   1. | 2.8    3 |
      +----------+

...
that's fine, but setting s to 0 still produces a swap

. local s=0

. swap if `s' ==1
(79 missing values generated)
(84 missing values generated)

. list r1 r2 in 1

      +----------+
      | r1    r2 |
      |----------|
   1. |  3   2.8 |
      +----------+

dropping the program does not help.

what am i doing wrong?

thanks.

paul

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

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