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 on April 23, and its replacement, is already up and running.

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

st: Re: Writing values to a file

From   Janet Hill <>
Subject   st: Re: Writing values to a file
Date   Wed, 8 Dec 2010 11:15:19 +0000 (GMT)

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.


*   For searches and help try:

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