Dear all,
I have a dataset which contain id number with the display format is %6.3f. And I would like to use substring command to create a new variable take the number before the dot '.'.
I mean if I have two subjects with their id are
And I want to create a variable cluster which has value equals 23 for the 1st one and equals 24 for the second one. The problem is part of the id's string ranges from 1 to 32, therefore, I can not use the following command
I read and use the following command, instead.
I know that the wrong code, but how to fix it.
Thank you all inadvance.
I have a dataset which contain id number with the display format is %6.3f. And I would like to use substring command to create a new variable take the number before the dot '.'.
I mean if I have two subjects with their id are
Code:
1. 23.149 2. 24.001
Code:
gen cluster=substr(id,1,2)
Code:
gen cluster=substr(id,-3,2)
Thank you all inadvance.
Comment