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

Re: st: variable


From   Russell Dimond <[email protected]>
To   [email protected]
Subject   Re: st: variable
Date   Fri, 08 Apr 2005 10:43:01 -0500

Hi Jorge,

If you want that leading zero in var03, making var01 into a string if it isn't already and using substr as Roger suggested is your best option.

But if you're working with numbers, the mod function and/or division with the result stored in an integer make it easy to break up variables by digit:

gen int var02=var01/1000000

gen int var03=mod(var01,1000000)/10000

gen int var04=mod(var01,10000)

Russell Dimond
Research Computing Specialist
Social Science Computing Cooperative
University of Wisconsin-Madison


Jorge Tuesta wrote:

Dear statlisters


I have this variable:


Var01
--------
23012005
17022005
.
.
.

i'd like this variables:

var02        var03          var04
-------        --------          ----------
23              01            2005
17              02            2005
.                 .                .
.                 .                .

How can i do?

thank´s in advance






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



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