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
Heteroskedasticity for Random EffectsHow can I test Heteroskedasticity in a Random Effects panel? I know xttest3 but it doesn't work in R…
Presenting Information Criteria in Latex form from StataHi guys, I would like to display my information criteria in choosing the lag length for the estimat…
Matching of Cases to reduce sample size of logit regressionHi everyone, I'm working on a study to investigate the impact of firm performance on probability of…
Droping "NA"sHi Stata users. I have 26 variables that contain some observations as NA. Is there a way ( olther t…
Using marginsplot, category labels and plots overlap.I use Stata 15.1 SE on Windows 10. I am calculating predictive margins following an ologit in the sv…
Subscribe to:
Post Comments (Atom)
0 Response to Creation of New Variable from Long Variable
Post a Comment