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
Line disappearsDear all, I'm doing a scatter plot (potassium levels in 2 distinct moments) with this code (which w…
Counting the number of groups in a permutation testI am trying to do a permutation test with yearly panel data. The treatment variable, "treat", has 7 …
Fixed effects stability test or Joint F test for fixed effectsHello every one, I have the wage gap between immigrants and natives Born by census metropolitan are…
What are the requirements to make causal inference when using correlated random effects (CRE)?Hello all, I am now self-learning how to use the correlated random effects model from the IZA confe…
Excel's XIRR function in StataHi Forum I am attempting to perform financial investment performance analysis. For small test samp…
Subscribe to:
Post Comments (Atom)
0 Response to parsing a variable based on digits
Post a Comment