[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Question regarding formatting in Sprintf command (Mata)

From   "Thomas Jacobs" <>
To   StataList <>
Subject   st: Question regarding formatting in Sprintf command (Mata)
Date   Tue, 16 Oct 2007 12:54:28 -0500

I am using the following routine to "export" a Mata matrix to Stata by
writing a text file which I then insheet into Stata and am confused
about why the sprintf command does not need to end with a \n newline

//Write Results matrix to file
fh = fopen("Results.txt", "w")

for (j=1; j<=rows(Results); j++) {

			Results[j,1],Results[j,2],Results[j,3], Results[j,4],



If I add the \n newline character I get my output file, Results.txt
with interspersed blank rows between each row of data.

I made the formatting %22.0g from %12.0g to see if the automatic
newline was caused by exceeding some predefined page width.  No matter
how I play with the field lengths I only get the appropriate file in
notepad or wordpad (under MS Windows) if I exclude the \n character.
I don't understand this behavior.  Can someone offer an explanation?



Thomas Jacobs
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index