Hi family,
I have a data set where the year of interview was taking from the last 2 digit. example, if it the respondent reported a year to be 1999 the year variable is captured as 99 and where it is reported as 2002, the year is captured as 2 or 2000 as 0. I wanted a command that could convert the last 2 digit back to 4digit. I tried severally but the system keep generating error.
Below is what used;
replace yearcent= (200*10+year, if year<10)|(19*100+year, if year>10)
The error message was "year,ifyear invalid name"
Find the data set below;
input float(id day month year)
103358 4 10 2
103460 20 2 1
103740 17 12 97
102922 19 7 97
103018 21 11 98
103362 3 5 99
103552 19 1 99
102112 1 12 2
102388 17 8 1
102998 27 5 1
103742 8 9 1
103752 1 7 0
103152 13 12 99
102044 28 9 2
102298 16 3 97
102946 26 4 97
103498 6 7 1
103528 18 10 0
103564 8 2 0
103660 30 10 2
102046 8 1 98
102478 3 12 97
103126 13 1 97
103316 23 8 99
102274 27 11 1
102300 14 9 1
102476 13 9 98
102654 28 3 1
103062 1 8 98
103282 21 9 99
103364 22 12 98
103786 22 6 2
102304 7 12 97
102348 3 2 1
102410 19 11 1
103390 11 6 98
102772 25 5 1
103202 3 3 0
103492 18 7 1
102070 3 1 1
102152 31 8 0
102372 6 8 99
102384 8 4 99
102788 5 9 2
102802 24 3 2
103472 11 7 0
103720 12 8 2
102218 30 8 98
102600 18 1 97
102820 25 9 99
102994 2 4 0
103122 26 3 97
103266 8 5 99
103640 14 6 2
102706 4 11 0
103010 7 4 97
103674 1 7 2
103770 5 9 0
102262 9 10 97
102190 20 1 99
103470 28 11 1
103486 15 8 97
102928 7 5 97
103400 30 4 2
103280 28 7 99
103726 27 3 1
102254 6 3 97
102620 20 3 98
103620 23 9 98
102650 17 7 0
102424 2 5 1
102132 12 1 98
102694 1 7 1
102234 25 12 2
102892 13 3 99
102942 16 7 0
103404 11 5 0
102986 9 7 99
102968 13 10 98
103168 6 9 97
103210 31 5 99
103542 6 7 0
102284 9 7 97
102658 7 3 2
102078 19 3 1
102592 2 7 1
103214 17 9 97
103684 22 4 98
102872 8 5 1
103676 6 11 97
102932 15 5 98
103338 19 1 0
102436 6 5 2
103416 27 7 0
102412 22 2 0
102500 11 2 98
102728 11 10 98
103538 8 9 2
103246 26 4 98
103436 31 5 97
end
Kindly help me out.
2. How do I format date of interview to comprise of day month and year (example: 22nd January 1998) using the above data set?
Thank you.
0 Response to Converting Year response into 4 digit year using the century and if condition
Post a Comment