Statalist The Stata Listserver


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

st: ifcmd question


From   "Robert Duval" <rduval@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: ifcmd question
Date   Sun, 12 Nov 2006 17:01:25 -0500

Dear all,

I am trying to pass a command to a whole dataset if a variable takes
certain values... For instance I would like Stata to save a file
hola.dat if variable x takes values >1...

I tried

if x>1 {
save hola.dat
}

but at execution Stata doesn't do anything.

Please note I don't want to filter obs. I just want the program to
save the current file under a given name if one of its variables takes
certain values.

The problem is that ifcmd evaluates an exp and the command save
applies to the whole dataset and not to a subset of obs.

Any suggestion how to get at my goal?
Thanks again in advance,
robert
*
*   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