Selection of cases with special digits within a longer variable
In Denmark, we have the unique CPR number consisting of birthdate (ddmmyy) followed by 4 numbers. If I have to select a population born in fx 1940 from a larger epidata-fil, I consider to use the export facility, but then need an observation filter only selecting those born in 1940, which means those numbered 40, in position 5 and 6 in the 10 digit CPR variable. Do anybody have knowledge of a relevant syntax for that?
Yours sincerely
Jes Lindholt Ass. professor, PhD Vascular Research Unit Viborg Hospital, Denmark E-mail: jes.s.lindholt@viborg.rm.dk
Do this:
define cprtxt __________ // string of length 10 define yrtxt __ // string of length 2 cprtxt = cpr yrtxt = copy(cprtxt,5,2) // digits 5 & 6 select yrtxt = "40"
This can also be done in a single line, if you have no other use for the year of birth:
select copy(cpr,5,6)="40"
Jamie Hockin
2009/10/27 Jes Lindholt wrote:
In Denmark, we have the unique CPR number consisting of birthdate (ddmmyy) followed by 4 numbers. If I have to select a population born in fx 1940 from a larger epidata-fil, I consider to use the export facility, but then need an observation filter only selecting those born in 1940, which means those numbered 40, in position 5 and 6 in the 10 digit CPR variable. Do anybody have knowledge of a relevant syntax for that?
participants (1)
-
epidata-list@lists.umanitoba.ca