[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: concat num var
> What is the easiest way to concat 4 numerical variables,
> each of various
> lengths (3-9). I tried :
> egen newvar=concat(var1 var2 ...)
> but got a newvar (16 to 18 digits) displayed in exponential
> format when it's
> longer than 16 digits, which I don't want. I tried to
> change the storage
> type and display format but wasn't able to see all 17 or 18 digits.
The answer to this overlaps with my previous
answer to Seyda.
As background, note that -egen, concat()-
takes any variables supplied, whether numeric
or string, and produces a composite string
First, there is perhaps some confusion here,
as string variables can only have string formats.
If characters such as "1.23e+08" are included,
then the only way to fix this is to go back
and redo whatever produced that. String
variables can not have exponential formats,
and messing with the format is not going
to change the content of the variable,
which is, I think, the issue.
You can supply a -format- argument
to control the concatenation in -egen, concat(),
but this necessarily applies to all numeric
Sometimes there is no alternative
but to spell out a format on
some conversions but not others.
That is, -egen, concat()- was written
as a short-cut, but sometimes you
need a more detailed specification.
To echo Rich Goldstein's reply,
this should be easy whenever it
is natural, so if matters remain
unclear please show concrete examples.
* For searches and help try: