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

From |
"Pedro Martins" <P.Martins@warwick.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: post |

Date |
Wed, 27 Nov 2002 19:06:39 +0000 |

thank you for this. but is it possible to use the -append- option in -outfile-? pedro **************************************************** Pedro Martins Department of Economics University of Warwick Coventry CV4 7AL United Kingdom Tel: +44/0 24765 28418 Fax: +44/0 24765 23032 Email: p.martins@warwick.ac.uk Web: www.warwick.ac.uk/staff/P.Martins ***************************************************** >>> n.j.cox@durham.ac.uk 11/27/02 06:40PM >>> Pedro Martins > > i want to save, in a while/do loop, certain observations of > a data set into another data set without closing the first > data set. it seems that -post- is the command i should use > but apparently i'm not following its syntax correctly. > > in a do-file, i wrote: > > postfile x1 x2 using filename, replace > local i=1 > while `i' <=20 { > here i change the sample and do things to variable y > post x1 x2 if y==1 > local i=`i'+1 > } > postclose > > x1 and x2 are the two variables i want to save in the > secondary dataset (without closing the primary one). can you help?! > Think of -post- as writing one record (one line) to a file each time it is invoked. That may not be what happens physically, i.e. as far as your computer is concerned, but it is the way to think about -post-. Therefore, -post- must be given expressions, each of which is, or evaluates to, single numbers. Also they must be parenthesised. Otherwise, Stata's interpreter could see results like 2 -1 and get it into its little head to evaluate that output as an algebraic expression. You can only use -post- to write variables if you loop over observations and write values from each observation out one at a time. Your syntax requires Stata to be smart enough to guess that you want some current value of -x1- and -x2- to be posted each time around the loop, but Stata needs that to be spelled out. For all that, it is not at all clear that -post- is what will serve you best. On this information, -outfile- seems more suitable. Nick n.j.cox@durham.ac.uk * * 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/

**Follow-Ups**:**st: RE: RE: post***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: RE: post** - Next by Date:
**RE: st: STATA Vs. SAS** - Previous by thread:
**st: Stata vs SAS thread** - Next by thread:
**st: RE: RE: post** - Index(es):

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