Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Re: Writing values to a file


From   "Airey, David C" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Re: Writing values to a file
Date   Wed, 8 Dec 2010 09:23:46 -0600

.


So are you saying you can determine the summary statistics you want, but you cannot write them out to a text file? Why would you not save the summary statistics out into a Stata data set or .csv file from a Stata data set? In other words is it really the data management that is throwing you or the writing out of data to text files?

> I would be grateful for some advice on writing a value to a file. I have a dataset where I need select a particular value, the first value exceeding a threshold value,and the process is repeated over 240 groups. I can list the values but I am unable to write the values to a file for subsequent use. My code - and I know it is awful programming - is:
> 
> capture : file close myfile
> file open myfile using "elong.txt", write replace
> 	file write myfile ("repeat,e") _n
> capture : drop marker
> gen marker=0
> forvalues i=1/24{
> replace marker=1 if repeat==`i' & ld > 0.001
> su id1 if marker==0 & repeat==`i'
> list group repeat l ls e if repeat==`i' & id1==r(min)
> 	file write myfile (e) if repeat==`i' & id1==r(min)
> 	file write myfile ","
> 	file write myfile (`i') _n
> }
> file close myfile
> 
> Many thanks.
> Janet




*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index