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: save list of scalars or locals to file


From   <[email protected]>
To   <[email protected]>
Subject   st: save list of scalars or locals to file
Date   Tue, 17 Apr 2012 09:45:51 +0200

Dan,

excellent solution. Fast and easy. Thank you very much! 

***

The four different - file write - lines for scalars/locals and double quoted/not double quoted in output file:

(scalars, not quoted in file)
file write `scs' `"`: display h`x''"' _n

(locals, not quoted in file)
file write `scs' `"`: display `"`h`x''"' '"' _n

(scalars, quoted in file)
file write `scs' `""`: display h`x''""' _n

(locals, quoted in file)
file write `scs' `""`: display `"`h`x''"' '""' _n


**********************************


Stefan,

Would writing it out to a txt file work for you?

tempname scs
file open `scs' using "C:\data\sc_data.txt", text write replace forvalues x = 1/`sc' {
   file write `scs' `" `: display h`x'' "' _n } file close `scs'

The line:
   file write `scs' `" `: display h`x'' "' _n

is a condensed version of these two lines:

   local temp : display h`x'
   file write `scs' `" `temp' "' _n

You may want to have the scalar values enclosed in double quotes inside the txt file:

   file write `scs' `""`: display h`x''""' _n

Hope this helps,
Dan Blanchette
Research Programming Services
Carolina Population Center
University of North Carolina
[email protected]



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