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, statalist.org is already up and running.


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

st: SV: RE: RE: SV: RE: SV: RE: SV: RE: postfile


From   "Tomas Lind" <tomas.lind@ki.se>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: SV: RE: RE: SV: RE: SV: RE: SV: RE: postfile
Date   Fri, 27 Aug 2010 14:18:48 +0200

Thanks Martin and Nick for all kind help (as usually),

I think I found the root of the problem. I have a variable called fönster (a
Swedish word for window in my syntax). Normally Swedish letters å, ä, ö are
allowed in variable names BUT not in this case obviously. In the syntax
below everything works fine when fönster is (mis)spelled with the letter "o"
(fonster). But I get an error if I spell fönster. 


drop *
input  id   x6   x12   z6   z12
        1    1    4     7    10
        2    2    5     8    11
        3    3    6     9    12
end

tempname  resul
postfile `resul'  str5 proxy   fonster  mean     using H:\Slask\slask2.dta ,
replace 	
						
foreach i in 6 12  {						
   foreach X of varlist   x`i' z`i'   {
	local  proxy    `X'
	local  fonster  `i'

	summarize `X' , meanonly
	local mean = r(mean)

    post  `resul'  ("`proxy'")  (`fonster')  (`mean')   
    }
}
postclose `resul'					// Stäng datasetet
som har xx rader och 5 variabler	


preserve
use H:\Slask\slask2.dta 	, replace	
list , noobs
restore








-----Ursprungligt meddelande-----
Från: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] För Martin Weiss
Skickat: den 27 augusti 2010 14:06
Till: statalist@hsphsun2.harvard.edu
Ämne: st: RE: RE: SV: RE: SV: RE: SV: RE: postfile


<>

Sorry I am currently out of town, so I cannot follow every development as
closely as I would like to. Tomas must have an obsession with -local-s,
which are quite unnecessary for his -postfile- setup, as the example shows.
Unless, of course, he wants to use the values somewhere else. And, as Nick
said, -in r- is short for -in red-.

*************
tempname myfile 

postfile `myfile' lowerbound time using postfiletest, replace
                                               
foreach i in 6 12 18 {     
	cii 1 `i', poisson                         
 	post  `myfile' (`r(lb)')  (`i')     
}

postclose `myfile'                              
u postfiletest, replace       
list , noobs
*************


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: Freitag, 27. August 2010 13:00
To: 'statalist@hsphsun2.harvard.edu'
Subject: st: RE: SV: RE: SV: RE: SV: RE: postfile

This works for me: 

. tempname myfile 

. postfile `myfile' time using postfiletest.dta , replace         
(note: file postfiletest.dta not found)
                                                 
. foreach i in 6 12 18 {                          
  2.         local  time  `i'        
  3.     post  `myfile'   (`time')     
  4.     }

. postclose `myfile'                              

. preserve

. use postfiletest, replace       

. list , noobs

  +------+
  | time |
  |------|
  |    6 |
  |   12 |
  |   18 |
  +------+

. restore

Nick 
n.j.cox@durham.ac.uk 

Tomas Lind

This works when I post the i (time-variable) so I suppose I am in the
vicinity of success (however I don´t understand why the full code doesn´t
work (error message r198 about the variable time).

clear
tempname  resul
postfile `resul'  time     using H:\Slask\slask2.dta , replace 	
						
foreach i in 6 12 18 {				
	local  time  `i'	
    post  `resul'   (`time')     
    }
postclose `resul'					

preserve
use H:\Slask\slask2.dta 	, replace	
list , noobs
restore

Nick Cox

I imagine that you need to look more carefully at the variable in question. 

Tomas Lind

I get the following error message (note, the variable time in my example
corresponds to the variable fönster in my real syntax so the error message
is about the variable fönster)



saba_L6

                                                         -- Binomial Exact
--
    Variable |        Obs        Mean    Std. Err.       [95% Conf.
Interval]
-------------+--------------------------------------------------------------
-
     saba_L6 |       3366    .0356506    .0031959        .0296445
.0424797



invalid syntax
post:  above message corresponds to expression 2, variable fönster
r(198);

end of do-file

r(198);


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


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


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index