Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: notes lost in append

From   David Kantor <>
Subject   Re: st: RE: notes lost in append
Date   Tue, 11 May 2004 11:15:19 -0400

To Devra Golbe:

As Fred alluded,
local note0 : char varname[note0]
will get you the number of notes for varname (but it is blank, not zero, when there are no notes for varname).
local note1 : char varname[note1]
local note1 : char varname[note2]
will get you the notes for varname.

(Substitute "_dta" for "varname" to get dataset notes.)

(note0, note1, etc are just arbitrary local macro names; varname represents some variable.)

You will need to load your "second" dataset, and capture the notes into macros as above. Then load your main dataset, append the second, and set the notes. But it will take some clever programming to do this over all possible variables (or perhaps a specified set of variables), and to possibly check for duplicate notes before setting them. In doing this, if you just use the -notes- command, the additional notes (regardless of whether duplicates were screened out) will be assigned additional note numbers . (Thus, if for a given variable, the first dataset has 1 note and the second has 2, then notes 1 and 2 in the second dataset will become notes 2 and 3 in the appended.)

I hope this helps.
-- David

P.S., I haven't tried this, but possibly, notes do get brought in from the using set when you -merge-. (I think this happens, but I'm not sure; needs testing.) If so, then you may be able to affect an
-append- by a -merge- -- if you use a match-merge with no matches, that is, no cases of matching identifier values between the datasets (_merge ~=3).

Again, I hope this helps.

At 09:48 AM 5/11/2004 -0400, you wrote:

I thank Fred and Nick for their responses to my question about appending notes.

For the short-term, I would be happy to try Fred's suggestion if only I could figure out how to do it. Having checked the documentation, I can't see how to retrieve the notes from a data set in order to copy them into a new data set. Are they stored in some retrievable variable?

For the long-term, I think it would be useful if -append- retained notes in the using data set, renumbering if necessary, and, if feasible, adding an option to add the source data set to the note.

At 02:25 PM 5/8/2004, Fred Wolfe wrote:

I think there is a possible work-around. As notes are stored as -var[note(n)]:-, one could pull off the notes from each data set prio to the append/merge, compare them and then merge them into the master set according to some rule. I could see how this might be useful.

David Kantor
Institute for Policy Studies
Johns Hopkins University

*   For searches and help try:

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