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]

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


From   Aaron Kirkman <ak1795mailserv@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How do I store the value of an observation to a note?
Date   Tue, 23 Oct 2012 06:57:59 -0500

Hi Phil,

That does exactly what I need. Thank you!

Aaron

On Mon, Oct 22, 2012 at 11:22 PM, Phil Clayton
<philclayton@internode.on.net> wrote:
> 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 <ak1795mailserv@gmail.com> 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/
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index