Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: postfile - posting a string


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: postfile - posting a string
Date   Mon, 21 Mar 2005 19:01:03 -0500

Try reading -help post-

As shown in the help file, you need to declare string variables in the postfile command line, for example

postfile `memhold' str8 var z1 z2

You must also post the actual string, not a valid reference to a variable name. As you do it now, `var' becomes mcd which Stata sees as a variable name and inserts mcd[1]. Instead you need to post "`var'" (use quotes).

Michael Blasnik
michael.blasnik@verizon.net


----- Original Message ----- From: "Danielle Ferry" <dferry@nber.org>
To: "StataList" <statalist@hsphsun2.harvard.edu>
Sent: Monday, March 21, 2005 6:10 PM
Subject: st: postfile - posting a string



Statalisters,
In the example below, I have a local variable containing a list of variable names, and in the <postfile> procedure I want to post each variable name in that list. In particular, I want the variable "var" in the tempfile "predictions" to be a string and to have an entry of "mcd" in obs 1 and an entry of "priv" in obs 2. The way it is currently written, it posts the VALUE of each variable in the list. Can anyone please help with this?
Much thanks,
Danielle Ferry

local insvars "mcd priv ";
tempname memhold;
tempfile predictions;

postfile `memhold' var z1 z2 using `predictions';

foreach var of varlist `insvars' {;
[do stuff] post `memhold' (`var') (`a') (`b');
};

postclose `memhold';

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