Statalist


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

st: re: creating a variable equal to the last number of another


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: creating a variable equal to the last number of another
Date   Fri, 16 Nov 2007 11:47:57 -0500

Victoria wants to do the opposite:

My problem is similar to Maria's, but from your command I cannot figure out how to apply it to my case.

Basically I just need to keep the first 2 digits of my variable "code".


. g firsttwo = substr(string(var1),1,2)

. l

+-----------------+
| var1 firsttwo |
|-----------------|
1. | 11 11 |
2. | 222 22 |
3. | 3333 33 |
4. | 4444 44 |
+-----------------+

Kit

Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


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