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

st: Re: generating a string from floats


From   "Zhiqiang Wang" <[email protected]>
To   <[email protected]>
Subject   st: Re: generating a string from floats
Date   Tue, 29 Oct 2002 09:30:22 +0930

Kompal wrote:
> Hi There,
> I have 5 variables(floats) in following format: (the first row looks like
> this):
>   x       y     z     t    q
> 123456  78965 12345 45678 56
>
> I want to make a new Identifier variable (preferably string) which just
puts
> the five variables side by side like:
> 12345678965123454567856
>
> I tried gen str23 caseid = x+y+z+t+q but it gives the error type mismatch.
> I also tried to convert floats to strings using stattransfer but it didn't
> work I am getting blank columns. I can't do it mathematically as the
number
> created will be more than sixteen digits and won't solve my purpose.
> How should I proceed???
>

Use -string- function:
. gen str23 caseid=string(x) +string(y) + string(z) + string(t) +string(q)

Zhiqiang
Menzies School of Health Research
Darwin Australia

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