Dear All,
I try to create a new variable (let's say caseid_copy) based on the original caseid. However, I have problems with its digits. The new variable should be constructed according to original caseid's digit numbers. That is, here is the original data: (I also attached how it looks like). Thank you many times!
caseid
101 8 2
1010 7 5
101010 2
101010 9
Here is the wanted data:
caseid_copy
101 8 (if caseid has three digits in the beginning, I want to drop the last digit which is 2 as above)
1010 7 (if caseid has four digits in the beginning, I want to drop the last digit of caseid which is 5 as above ))
10101 (if caseid has five digits in the beginning, I want to drop the last digit of caseid which is 2 as above . That is, I want to see only the first five digits)
101010 (if caseid has six digits in the beginning, I want to drop the last digit of caseid which is 9 as above. That is,I want to see only the first six digits ) Array
Related Posts with parsing a variable based on digits
asreg : Updated 2021: new flexible window | Fastest rolling regressions in StataThanks to Kit Baum, the updated version of asreg is now available on the SSC. The new version is ver…
Heterogeneity and Variability of variables for selected cases in Panel DataDear All, I have a panel data with three waves and i am comparing the mean difference (mean comparis…
gmatch and psmatch2I am trying to conduct a logistic regression after propensity score matching. I tried both gmatch ps…
Treatment effect model suggestion using StataHi all, I want to develop my model to assess the relationship between traffic accident and repair o…
C-statistic at specific point in time.Dear all Sorry if this topic has been previously addressed, but could not find it here or elsewhere…
Subscribe to:
Post Comments (Atom)
0 Response to parsing a variable based on digits
Post a Comment