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
STREG, dist coefficientHello, I am trying to do survival analysis. STREG has several options like streg X1 X2, dist(exp) …
Reshape long complicatedHi Statlist, I have a question for you about reshaping command. I have a quarterly sales dataset a…
Is the interpretation of a fisher unit root test biased if data are severely unbalanced?I have unbalanced data for N=1227 and T=142. My data is severely unbalanced and when I run the fishe…
Exporting two-way tabulation results to excel (in stata 14)Hello, I want to export two-way tabulation using (row option and survey weights) results to excel. …
Rename a variable with contentHello, I would like to rename a variable (suppose it's name is VAR) with the content that is in a s…
Subscribe to:
Post Comments (Atom)
0 Response to parsing a variable based on digits
Post a Comment