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
Reporting probit/logit marginal effects for interaction terms in regression tableHi all, As is well known by many on this forum, there are some difficulties with calculating margin…
My dataset has corrupted and was automatically edited or changed........how to fix this?Dear statalist users, Since yesterday, my dataset has changed wired. I have been doing lots of regre…
question about heatplot?Dear all, I want to use heatplot command to plot correlation coefficients graph. here is the example…
Line graph/ Monthly dataDear Stata users I have monthly data on stock prices form Jan-2019 to March-2020 for three types of …
Different symbols for markers in scatterplotHello dear Stata-Pros! I need to create a scatterplot with markers differing optically. One spot sh…
Subscribe to:
Post Comments (Atom)
0 Response to Creation of New Variable from Long Variable
Post a Comment