help for bynote                                                  (Roger Newson)

Create a note with a user-specified format for use with the by option

bynote varlist [ , prefix(string) separator(string) lseparator(string) suffix(string) local(name) ]


bynote creates a note for use as the note() suboption of the by-option of the graph command. This note is made up of the variable labels of the variables in the varlist, if these labels exist, and of the names of these variables otherwise. The user can specify a format for this note, and/or save it in a local macro. The by-option automatically sets the overall note() suboption to a list of by-variable names and/or labels by default, but it does not always have the format that the user wanted, and may not use all the variable labels.


prefix(string) specifies a string to use as the prefix for the by-note. If not set by the user, it is set by default to "Graphs by: ".

separator(string) specifies a string to use as the separator between successive variable labels (or names). If not set by the user, it is set by default to ", ", implying comma separation.

lseparator(string) specifies a special separator to separate the last variable label (or name) from the immediate previous variable label (or name). If not set by the user, it is set by default to the value of the separator() option. The lseparator() option allows the user to specify notes such as "Graphs by: Repair Record 1978, Car type and Trunk space (cu. ft.)" by specifying lseparator(" and ").

suffix(string) specifies a string to use as the suffix for the by-note. For instance, the user may want the by-note to end with a full stop. If not set by the user, it is set by default to the empty string "", implying no suffix.

local(name) specifies the name of a local macro in which the by-note is to be stored.


. bynote foreign rep78 . scatter mpg weight, by(foreign rep78, note("`r(bynote)'"))

. bynote foreign rep78 trunk

. bynote rep78 foreign trunk, prefix("Plots by ")

. bynote foreign rep78 trunk, se(" & ") pr("Plots by ") su(.)

. bynote foreign rep78 trunk, lo(locby)

. bynote rep78 foreign trunk, prefix("Graphs by ") lse(" and ")

Saved results

bynote saves the following in r():

Macros r(bynote) by-note created by bynote


Roger Newson, National Heart and Lung Institute, Imperial College London, UK. Email: r.newson@imperial.ac.uk

Also see

Manual: [G] by_option On-line: help for by_option