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]

Re: st: How do I store the value of an observation to a note?


From   Phil Clayton <[email protected]>
To   [email protected]
Subject   Re: st: How do I store the value of an observation to a note?
Date   Tue, 23 Oct 2012 15:22:59 +1100

Have you tried something like this?

----------
sysuse auto, clear
quietly count
forvalues n = 1/`r(N)' {
	note: `=make[`n']'
}
notes
----------

Phil


On 23/10/2012, at 1:14 PM, Aaron Kirkman <[email protected]> wrote:

> Dear Statalist,
> 
> I have a raw data set that includes a --notes-- variable with
> miscellaneous notes about the data set stored in each observation.
> These notes aren't related to the observations with which they are
> paired. I'm trying to loop through the observations and store each
> value of the --notes-- variable to a new note in the dataset. So far,
> I tried this:
> 
> ##
> 
> sysuse auto, clear
> quietly count
> forvalues n = 1/`r(N)' {
> 	note: make[`n']
> }
> notes
> 
> ##
> 
> but this stores the text -- make[...] -- to individual notes, as shown:
> 
> ##
> 
>  1.  from Consumer Reports with permission
>  2.  make[1]
>  3.  make[2]
>  4.  make[3]
>  5.  make[4]
>  6.  make[5]
>  7.  make[6]
>  8.  make[7]
>  9.  make[8]
> 10.  make[9]
> ...
> 
> ##
> 
> I can write the notes to a file with code like this:
> ##
> 
> sysuse auto, clear
> quietly count
> file open fh using "notes.txt", write replace
> forvalues n = 1/`r(N)' {
> 	file write fh (make[`n']) _n
> }
> file close fh
> 
> ##
> 
> but I would like to store the notes to the dataset, if possible.
> Simply wrapping parentheses around the -- notes[`n'] -- line in the
> first sample, as done in the second sample, does not work (the
> parentheses simply show up in the notes with the contents otherwise
> unchanged).
> 
> Thank you,
> 
> Aaron Kirkman
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index