Hi all
I have a date-variable 'x_yyww' taking on values where it is showing year and week in the format yyww. For example, when the variable takes the value 1450 it is week 50 in the year 2014. I want to convert this variable, so it instead shows the stata serial number for the first day of the week (with mondays beginning the week). Continuing the example the value 1450 should be converted to the stata serial number for the date 8/12/2014 (in the dd/mm/yyyy format).
I have another variable 'x_yyyymm' taking on values where it is showing the year and month in the format yymmm. For example, when the variable takes the value 201412 it is december 2014. Again, I want to convert this variable, so in instead shows the stata serial number for the first day of the month. For the value 201412 this would be the stata serial number for 1/12/2014.
Dataexample for the month variable:
Data example for the week variable:
I have a date-variable 'x_yyww' taking on values where it is showing year and week in the format yyww. For example, when the variable takes the value 1450 it is week 50 in the year 2014. I want to convert this variable, so it instead shows the stata serial number for the first day of the week (with mondays beginning the week). Continuing the example the value 1450 should be converted to the stata serial number for the date 8/12/2014 (in the dd/mm/yyyy format).
I have another variable 'x_yyyymm' taking on values where it is showing the year and month in the format yymmm. For example, when the variable takes the value 201412 it is december 2014. Again, I want to convert this variable, so in instead shows the stata serial number for the first day of the month. For the value 201412 this would be the stata serial number for 1/12/2014.
Dataexample for the month variable:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte pnr long x_yyyymm byte arbsted 1 201809 1 1 201810 0 1 201811 1 2 201809 0 2 201810 1 2 201811 1 4 201809 0 4 201810 1 4 201811 0 5 201809 1 5 201810 1 5 201811 1 7 201809 1 7 201810 1 7 201811 0 8 201809 0 8 201810 0 8 201811 1 end
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte pnr int x_yyww 1 1836 1 1837 1 1838 1 1839 1 1840 1 1841 1 1842 1 1843 1 1844 1 1845 1 1846 1 1847 1 1848 2 1836 2 1837 2 1838 2 1839 2 1840 2 1841 2 1842 2 1843 2 1844 2 1845 2 1846 2 1847 2 1848 4 1836 4 1837 4 1838 4 1839 4 1840 4 1841 4 1842 4 1843 4 1844 4 1845 4 1846 4 1847 4 1848 5 1836 5 1837 5 1838 5 1839 5 1840 5 1841 5 1842 5 1843 5 1844 5 1845 5 1846 5 1847 5 1848 7 1836 7 1837 7 1838 7 1839 7 1840 7 1841 7 1842 7 1843 7 1844 7 1845 7 1846 7 1847 7 1848 8 1836 8 1837 8 1838 8 1839 8 1840 8 1841 8 1842 8 1843 8 1844 8 1845 8 1846 8 1847 8 1848 end
Comment