Dear STATALIST Community Members,
Can you please take the time to solve my problem?
The value of the variable code is a 14-digit value and is the region code plus the year and month. For example, 11230560/2019/06.
gen double code_w = code*10 + week_day
format %20.0g code_w
gen double code_t = code*100 + week_day*10 + de_hr_grp
format %20.0g code_t
/*
The variable week_day has values 1 and 2 for weekday and weekend, respectively.
The variable de_hr_grp stands for hours (6-12-12-18-18-24) and has values 1,2,3, respectively.
*/
gen item=1 if newv1==1
replace item=2 if new3==2
replace item=3 if new3==7
replace item=4 if new3==12
replace item=5 if new3==23
*The variable item is the item I specified and I assigned the values 1,2,3,4,5.
*So, the last time I typed the command below, the end numbers of the output should be 1 through 5. However, my output only shows 2 and 6. What is the problem ?
gen double code_i = code_t*10 + item
format %20.0g code_i
*results of command 'tab code_i'
1.17e+16 | 114 0.00 99.96
1.17e+16 | 160 0.00 99.96
1.17e+16 | 42 0.00 99.96
1.17e+16 | 1 0.00 99.96
1.17e+16 | 5 0.00 99.96
1.17e+16 | 717 0.01 99.98
1.17e+16 | 121 0.00 99.98
1.17e+16 | 158 0.00 99.98
1.17e+16 | 796 0.02 100.00
1.17e+16 | 33 0.00 100.00
1.17e+16 | 37 0.00 100.00
------------+-----------------------------------
Total | 5,062,296 100.00
Thank you
Can you please take the time to solve my problem?
The value of the variable code is a 14-digit value and is the region code plus the year and month. For example, 11230560/2019/06.
gen double code_w = code*10 + week_day
format %20.0g code_w
gen double code_t = code*100 + week_day*10 + de_hr_grp
format %20.0g code_t
/*
The variable week_day has values 1 and 2 for weekday and weekend, respectively.
The variable de_hr_grp stands for hours (6-12-12-18-18-24) and has values 1,2,3, respectively.
*/
gen item=1 if newv1==1
replace item=2 if new3==2
replace item=3 if new3==7
replace item=4 if new3==12
replace item=5 if new3==23
*The variable item is the item I specified and I assigned the values 1,2,3,4,5.
*So, the last time I typed the command below, the end numbers of the output should be 1 through 5. However, my output only shows 2 and 6. What is the problem ?
gen double code_i = code_t*10 + item
format %20.0g code_i
*results of command 'tab code_i'
1.17e+16 | 114 0.00 99.96
1.17e+16 | 160 0.00 99.96
1.17e+16 | 42 0.00 99.96
1.17e+16 | 1 0.00 99.96
1.17e+16 | 5 0.00 99.96
1.17e+16 | 717 0.01 99.98
1.17e+16 | 121 0.00 99.98
1.17e+16 | 158 0.00 99.98
1.17e+16 | 796 0.02 100.00
1.17e+16 | 33 0.00 100.00
1.17e+16 | 37 0.00 100.00
------------+-----------------------------------
Total | 5,062,296 100.00
Thank you
Comment