The help for -egen, concat()- is
concat(varlist) [, format(%fmt) decode maxlength(#) punct(pchars)]
may not be combined with by. It concatenates varlist to produce a
string variable. Values of string variables are unchanged. Values
of numeric variables are converted to string, as is, or converted
using a format under option format(%fmt) or decoded under option
decode, in which case maxlength() may also be used to control the
maximum label length used. By default, variables are added end to
end: punct(pchars) may be used to specify punctuation, such as a
space, punct(" "), or a comma, punct(,).
That is, the -format()- option specifies a numeric format to
be used in the mapping to string. It does not specify a
string format to be used for the string variables themselves.
A glance at the code using
. viewsource _gconcat.ado
shows that the argument of -format()-, when supplied, is
passed to the -string()- function, which takes a real
argument and optionally a numeric format.
Thus you need to apply -format- after the -egen- call.
Nick
[email protected]
b. water
> thanks nick for your reply. it turns out that -trim()- was
> not what i was
> looking for. i managed to get what i want (99% of it in any
> case) by trial
> and error with helps from the manual (i looked at append,
> merge, trim and
> searched for concat, where i stumbled upon egen option that
> did the trick).
> this is the command that i used:
>
> egen studynyr = concat (study year), punct(" ")
>
> i tried to right justify the apperance of studynyr by adding
> format (%15s)
>
> i.e.: egen studynyr = concat (study year), format (%15s) punct(" ")
>
> but keep getting 'Invalid format'. however when i list the
> data, appearance
> seems to be as i like it so i might not have to force right
> justification
> but i would still appreciate advice on how to get the right
> justification
> command correct.
Nick Cox
> >When you say merge, I guess you mean
> >concatenate.
> >
> >Assumed that you have applied -trim()-,
> >right-alignment is a matter of format,
> >not of what the values are, nor of how
> >they are held informally.
> >
> >You should read up the help on formats.
b. water
> > > i have two variables: studynames and yearofstudy e.g. Alshop
> > > 1981, Bell 1992.
> > >
> > > what i want to do is to merge the two variables such that:
> > > Alshop 1981
> > > Bell 1992
> > > i.e. somehow it is right-aligned in each cell.
> > >
> > > would be grateful for help in achieving this.
> > >
> > > platform: stata 8.2, os wxp pro sp2.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/