Statalist The Stata Listserver

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

Re: st: Re: ifcmd question

From   "Robert Duval" <[email protected]>
To   [email protected]
Subject   Re: st: Re: ifcmd question
Date   Sun, 12 Nov 2006 17:39:07 -0500

Hi Michael,

This does the trick...


On 11/12/06, Michael Blasnik <[email protected]> wrote:
..Not completely clear what you want, but if x>1 evaluates the first
observation of x and compares that to 1, it doesn't look for any x > 1.
Here's something that might do what you want:

sum x, meanonly
if r(max)>1 save hola.dat

Michael Blasnik

----- Original Message -----
From: "Robert Duval" <[email protected]>
To: <[email protected]>
Sent: Sunday, November 12, 2006 5:01 PM
Subject: st: ifcmd question

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

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index