This may work:
gen new=real(substr(string(original),1,4))
(I don't know how hypothetical your numbers are, but if your variable
"original" reports dates, check out -help date functions- to extract,
say, the year).
HTH,
Philipp
FUKUGAWA, N. wrote:
> Dear Statalisters,
> I would like to make a change in a variable.
> A new variable keeps only first four figures of ten-digit variable.
>
> original -> new
> 1980000123 -> 1980
> 1996123456 -> 1996
>
> How do I generate such variable using Stata?
> Thank you in advance.
> ---
> FUKUGAWA Nobuya, Ph.D.
> [email protected]
> See my works at www.ssrn.com
> *
> * 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/
>
>
*
* 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/