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
Truncating numerical dates to yearsI am trying to merge a few datasets, and one of them uses very specific date information in a format…
COEFPLOT, MLABEL(): Line break appears on PNG but not PDFHello all, I am using COEFPLOT and trying to add a line break to the marker label. Specifically, at …
Row totals for after a specific event occursHello! I'm certain there is a simple answer to this, so please feel free to direct me to the resour…
Problem with localsMinor but annoying problem with locals. I have a long variable list that I would like to add to a fi…
Large panel model: counting time periods since variable ==1Hi I have a very large panel dataset (50 time periods, 30m panel IDs) and I have a variable (called…
Subscribe to:
Post Comments (Atom)
0 Response to Creation of New Variable from Long Variable
Post a Comment