Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Outputing variables values in to a file


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Outputing variables values in to a file
Date   Fri, 28 Sep 2012 08:58:30 +0100

Aaron is right. In fact, pointing to -display- was perhaps
misdirection on my part.

Pradipto wants to write a text file, so -file- is good. From the
problem description you could also assemble the output as values of a
string variable, so long as each line was <= 244 characters, and then
just -outfile- that string variable.

Nick

On Fri, Sep 28, 2012 at 12:56 AM, Aaron Kirkman
<ak1795mailserv@gmail.com> wrote:
> Going along with what Nick said, two nested loops should do the trick.
> To write to a file, the -file- command should do what you want.
>
> http://www.ats.ucla.edu/stat/stata/faq/filewrite.htm
>
> On Thu, Sep 27, 2012 at 6:34 PM, Nick Cox <njcoxstata@gmail.com> wrote:
>> Looks like two nested loops with a -display- statement in the middle.
>>
>> Nick
>>
>> On Fri, Sep 28, 2012 at 12:11 AM, Pradipto Banerjee
>> <pradipto.banerjee@adainvestments.com> wrote:
>>
>>> Suppose I have N columns & M rows of data in a Stata dta file like this:
>>>
>>>
>>>        c1       c2      ... cN
>>>
>>> r1      3       4       ... 6
>>> r2      1       2       ... 7
>>> .       .       .       ....
>>> .       .       .       ....
>>> rM      3       9       ... 1
>>>
>>>
>>> I want to output a text file with as follows:
>>>
>>> line 1 is "3 w1 + 1 w2 + .... + 3 Wm >= 1"
>>> line 2 is "4 w1 + 2 w2 + .... + 9 Wm >= 1"
>>> .
>>> Line N is "6 w1 + 7 w2 + ... + 1 Wm >= 1"
>>>
>>> Can someone help me about how to write/output such a text file?
>>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index