Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: how to keep first four figures of a variable


From   Friedrich Huebler <huebler@rocketmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: how to keep first four figures of a variable
Date   Sat, 8 Jul 2006 16:20:03 -0700 (PDT)

Nobuya,

You can generate the new variable with the command below. This only
works if the original variable is in numeric and not string format.

. gen new = floor(original/1000000)

Friedrich Huebler

--- "FUKUGAWA, N." <nfukugawa@gmail.com> 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.
> nfukugawa@gmail.com
> See my works at www.ssrn.com


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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/



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