3
votes

I want to export data from Stata into a csv-file:

 outsheet "$dirLink/analysis.csv",  replace comma

but I got the following error message:

 factor variables and time-series operators not allowed
 r(101);

I couldn't find the solution in the net. Thanks for help.

Here are the variable definitions:

 tab0            str1   %9s                    
 linkid          float  %10.0g                 
 recid2          float  %9.0g                  
 recid1          float  %10.0g                 
 patient1        str28  %28s                   
 patient2        str9   %9s                    
 totwght         int    %10.0g                 
 status          str1   %9s                    
 fname           str13  %13s                   
 sname           str13  %13s                   
 doby            int    %10.0g                 
 cohort          str2   %9s    
 res1            str27  %27s                   
 res2            str29  %29s                   
 residence       str50  %50s   
 facility        str22  %22s                   
 maxwght         int    %10.0g  
1

1 Answers

8
votes

The syntax should be

outsheet using "$dirLink/analysis.csv",  replace comma

That is, the word using is required. This is documented in the help: no need for an internet search. It is true that the error message is not transparent, because Stata is guessing that you are trying something other than using or a variable list, either of which could follow outsheet.

P.S. in my answer to your previous question I pointed out that the correct spelling is Stata: see http://www.stata.com/support/faqs/resources/statalist-faq/#spell That's still true.