Hello Everyone,
I am currently working on a "long" variable of 9 digits and want to make a new variable consisting of first 4 digits of long variable. I used the following command where x is the long variable and y is new first four element variable:
gen id=string(x)
gen y=substr(id,1,4)
However, i am getting decimals whereas the original long variable do not have decimals example:
for x=110100101
i am getting y = 1.10
whereas it want is 1101
Please Help. Thanks in advance.
Regards
Related Posts with Creation of New Variable from Long Variable
variable already defined error in the foreach loopHello, I am trying to make a use of the Python-Stata interface in Stata foreach loop. My loop is sho…
Best Panel Data ModelI got a problem about panel data, I have micro panel data with 15.689 observation in 7 years. when …
Need help with psmatch2Dear Members of Statalist, this is my first post here in this forum. First of all, I am using Stata…
"Count if" with two conditionsHi everyone, I have cross-sectional loan data from 2007-2010. For each year I have at least 100 obs…
Problem with interpreting coefficients of multiple linear regression with indicesHello, I am working on a small research assignment and trying to identify drivers of the corruption…
Subscribe to:
Post Comments (Atom)
0 Response to Creation of New Variable from Long Variable
Post a Comment