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

st: RE: concat num var


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: concat num var
Date   Mon, 21 Oct 2002 21:07:27 +0100

Wentworth, Seyda

> 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
variable. 

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 
variables processed. 

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. 

Nick 
[email protected] 

*
*   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/



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