Hi just quick clarification needed on Reshape.
I start with data that looks like:
----------------------- copy starting from the next line -----------------------
I run:
And end with data that looks like:
----------------------- copy starting from the next line -----------------------
I need the Reshape to take the unique identifier of Regionname (aka ZipCode) into Variable names, then take dates starting from 2010m1 which is represented from X8. The method I'm using reshape seems to keep Regionname (Zip) all the way down. I instead would need each different zip as a different variable -- while all together vertically spanning the dates 2010m1 to date.
I'm pretty confident it's a quick fix in my code but any help is appreciated.
I start with data that looks like:
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long regionname int(v8 v9 v10 v11 v12 v13 v14 v15 v16 v17) 91342 476 463 400 346 327 350 338 322 341 344 91335 357 318 297 255 242 233 231 230 237 265 91331 340 300 268 265 245 231 230 228 229 242 91801 54 54 55 57 61 64 59 66 70 74 91367 290 258 245 241 232 243 250 249 262 250 91406 288 247 230 200 188 190 186 182 185 189 91706 126 116 111 105 102 101 100 110 117 123 91766 116 94 117 124 128 138 129 131 152 160 91744 110 106 102 105 110 116 129 134 147 157 91702 110 96 110 104 94 99 102 112 127 142 91770 49 48 51 57 54 60 62 69 71 75 91304 276 250 221 204 193 187 184 186 200 220 91344 268 230 191 186 178 199 202 202 208 211 91745 104 98 134 148 145 136 140 147 152 167 91765 159 148 158 170 172 194 208 222 224 219 91605 142 130 130 117 101 107 116 120 124 126 91016 84 94 107 118 110 122 113 120 132 128 91320 250 226 229 232 216 203 214 213 204 214 91423 272 254 232 208 203 203 204 208 200 218 91732 44 42 48 45 47 47 56 63 75 77 91401 153 154 156 160 163 177 168 163 169 177 91360 168 156 158 156 129 137 140 148 157 152 91604 262 238 244 240 249 258 236 236 233 249 91767 121 119 113 112 93 98 114 117 143 149 91387 368 360 315 276 251 247 248 264 270 278 91748 74 64 73 82 82 85 85 94 107 117 91306 264 244 227 214 192 200 200 195 204 212 91607 118 112 109 102 82 87 72 83 89 96 91311 298 269 251 237 212 220 229 230 250 257 91362 336 302 283 262 236 254 270 282 247 259 91750 105 104 101 92 93 109 107 103 109 116 91107 90 96 98 97 98 110 122 127 126 138 91104 86 85 86 96 94 96 98 90 96 98 91789 86 66 84 91 90 102 114 131 135 144 91773 94 91 107 112 112 119 114 113 123 134 91711 111 96 106 99 98 108 106 120 135 144 91754 34 30 38 38 40 42 44 45 54 52 91355 256 278 249 237 213 215 210 214 216 233 91001 104 98 108 120 117 119 129 128 134 137 91350 242 262 247 234 224 220 218 223 250 265 91316 284 250 259 227 212 206 203 220 214 222 91780 56 56 64 62 60 64 69 74 78 74 91776 38 34 44 37 32 39 37 36 34 42 91325 152 154 117 120 115 109 126 128 140 146 91403 182 169 150 152 155 148 146 152 178 168 91352 138 147 138 114 108 116 106 108 115 115 91356 297 300 283 262 244 232 228 240 255 261 91007 57 62 61 72 76 85 85 88 85 72 91106 86 96 97 106 102 114 114 112 106 108 91722 60 58 67 72 82 96 94 98 108 116 91321 225 222 205 216 218 206 202 209 215 202 91791 74 82 85 86 88 88 91 95 102 110 91354 298 296 232 216 210 230 238 248 254 234 91006 82 86 101 104 104 115 112 118 110 112 91214 98 102 98 97 98 108 114 103 104 96 91030 36 43 49 52 46 41 45 48 47 45 91803 21 22 31 34 32 36 36 42 42 42 91351 315 308 274 242 226 215 218 234 238 238 91364 268 272 218 192 178 194 200 215 218 216 91042 93 99 98 100 94 102 102 101 102 110 91602 158 151 161 152 143 142 134 136 134 132 91752 109 96 90 103 93 94 106 118 120 119 91303 88 78 68 72 74 76 72 68 71 80 91504 94 102 93 94 93 94 106 104 102 106 91740 60 59 70 68 64 72 66 68 68 62 91302 431 406 373 342 332 316 309 324 317 312 91301 247 222 216 203 192 199 200 202 189 183 91792 52 46 65 66 60 70 78 76 86 92 91741 92 102 116 116 114 124 120 122 124 128 91411 97 87 80 68 66 74 76 74 74 70 91103 89 86 89 91 82 79 89 100 101 97 91724 58 54 62 64 68 74 82 92 92 98 91361 306 248 236 246 223 218 218 220 192 182 91307 220 200 173 166 153 167 178 174 179 180 91775 41 39 40 48 53 58 63 61 57 54 91768 82 71 76 74 70 68 69 74 78 86 91010 53 55 57 58 50 53 58 64 79 82 91040 123 129 119 114 110 114 115 120 117 104 91384 217 196 180 170 154 164 172 179 177 182 91011 88 76 77 84 75 81 80 75 86 81 91381 188 184 151 152 135 161 169 166 165 159 91746 40 38 47 51 50 45 46 50 50 56 91390 226 220 186 174 168 158 160 169 177 168 91105 78 70 64 72 74 86 88 84 81 84 91436 161 144 110 110 104 102 108 120 119 124 91024 36 36 37 50 52 52 52 51 52 54 end
I run:
Code:
rename (v8-v106) X= rename X* X#, renumber gen long obs_no = _n reshape long X, i(obs_no) j(month)
And end with data that looks like:
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long regionname byte date int X 91001 1 104 91001 2 98 91001 3 108 91001 4 120 91001 5 117 91001 6 119 91001 7 129 91001 8 128 91001 9 134 91001 10 137 91001 11 134 91001 12 121 91001 13 112 91001 14 116 91001 15 120 91001 16 123 91001 17 131 91001 18 133 91001 19 136 91001 20 144 91001 21 116 91001 22 114 91001 23 119 91001 24 114 91001 25 106 91001 26 111 91001 27 118 91001 28 111 91001 29 103 91001 30 98 91001 31 96 91001 32 91 91001 33 94 91001 34 95 91001 35 100 91001 36 83 91001 37 76 91001 38 80 91001 39 72 91001 40 58 91001 41 76 91001 42 68 91001 43 82 91001 44 78 91001 45 68 91001 46 64 91001 47 64 91001 48 66 91001 49 48 91001 50 50 91001 51 65 91001 52 59 91001 53 66 91001 54 74 91001 55 80 91001 56 78 91001 57 84 91001 58 91 91001 59 91 91001 60 74 91001 61 48 91001 62 56 91001 63 66 91001 64 66 91001 65 80 91001 66 86 91001 67 79 91001 68 78 91001 69 73 91001 70 79 91001 71 68 91001 72 51 91001 73 35 91001 74 36 91001 75 48 91001 76 58 91001 77 61 91001 78 70 91001 79 77 91001 80 77 91001 81 58 91001 82 60 91001 83 52 91001 84 48 91001 85 40 91001 86 39 91001 87 40 91001 88 45 91001 89 47 91001 90 42 91001 91 43 91001 92 47 91001 93 54 91001 94 48 91001 95 37 91001 96 37 91001 97 41 91001 98 48 91001 99 52 91006 1 82 end
I need the Reshape to take the unique identifier of Regionname (aka ZipCode) into Variable names, then take dates starting from 2010m1 which is represented from X8. The method I'm using reshape seems to keep Regionname (Zip) all the way down. I instead would need each different zip as a different variable -- while all together vertically spanning the dates 2010m1 to date.
I'm pretty confident it's a quick fix in my code but any help is appreciated.
Comment