Hi,

I want to graph the development of the number of houses of the type "allmännyttan" (publicly owned housing) over time in Swedish municipalities. I have panel data on municipality level between 1975 - 2018, not all years though. I use the variable log_allmannyttan (log of the variable with the number of public owned houses in each municipality and year) as my main variable of interest and there are 290 municipalities. Now I want to graph the time trends, and include the development of the mean and some specific regions.

I have created a population weighted mean of the number of public houses each year (log variable name log_popwm_allmannyttan) that I want to plot over time, but I also want to include lines that show the time trend in certain municipalities where the number of houses increased most, decreased most, etc, to show the spread. (I can't include all because 290 lines will be to cluttered.)

When I try this simple code, it yields a graph with two lines, excluding one of the regions I specified. I have tried including more cases as well, usually one or two are excluded in the graph; it seems arbitrary to me which one that are included. Could anyone help me with a suitable code for creating this graph?

The code I tried:
Code:
line log_popwm_allmannyttan year, sort || line log_allmannyttan year if region_code == 360, sort || line log_allmannyttan year if region_code == 536, sort
Data example:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int(year region_code) str22 region_name long allmannyttan_owner float(log_allmannyttan popwm_allmannyttan log_popwm_allmannyttan)
1975  136 "Haninge"        9300   9.13777 15727.272 9.663152
1975 1487 "Vänersborg"    2416  7.789868 15727.272 9.663152
1975 2061 "Smedjebacken"   1577   7.36328 15727.272 9.663152
1975 1907 "Surahammar"      650  6.476973 15727.272 9.663152
1975 2183 "Bollnäs"       3177  8.063693 15727.272 9.663152
1975 2326 "Berg"            166  5.111988 15727.272 9.663152
1975 1490 "Borås"         9649  9.174609 15727.272 9.663152
1975 1465 "Svenljunga"      324  5.780744 15727.272 9.663152
1975 1489 "Alingsås"      2138  7.667626 15727.272 9.663152
1975  682 "Nässjö"       2473  7.813187 15727.272 9.663152
1975 2313 "Strömsund"      937  6.842683 15727.272 9.663152
1975 1401 "Härryda"       1256  7.135687 15727.272 9.663152
1975  685 "Vetlanda"        662  6.495265 15727.272 9.663152
1975  880 "Kalmar"         2622  7.871693 15727.272 9.663152
1975  763 "Tingsryd"        678  6.519147 15727.272 9.663152
1975 2417 "Norsjö"          95  4.553877 15727.272 9.663152
1975  821 "Högsby"         392  5.971262 15727.272 9.663152
1975 2421 "Storuman"         92 4.5217886 15727.272 9.663152
1975 1466 "Herrljunga"      350  5.857933 15727.272 9.663152
1975 1494 "Lidköping"     1343  7.202661 15727.272 9.663152
1975  187 "Vaxholm"         629  6.444131 15727.272 9.663152
1975  512 "Ydre"             98 4.5849676 15727.272 9.663152
1975  662 "Gislaved"       1603  7.379632 15727.272 9.663152
1975  182 "Nacka"          6759   8.81863 15727.272 9.663152
1975 1485 "Uddevalla"      4864  8.489616 15727.272 9.663152
1975  160 "Täby"           690  6.536692 15727.272 9.663152
1975 2321 "Åre"            163   5.09375 15727.272 9.663152
1975 1081 "Ronneby"        2176  7.685244 15727.272 9.663152
1975  580 "Linköping"    12177  9.407304 15727.272 9.663152
1975 1214 "Svalöv"         756  6.628041 15727.272 9.663152
1975 1498 "Tidaholm"        304  5.717028 15727.272 9.663152
1975 1284 "Höganäs"      1239   7.12206 15727.272 9.663152
1975 1760 "Storfors"        698  6.548219 15727.272 9.663152
1975 1290 "Kristianstad"   4680  8.451054 15727.272 9.663152
1975 1781 "Kristinehamn"   2223  7.706613 15727.272 9.663152
1975 2085 "Ludvika"        3424  8.138565 15727.272 9.663152
1975 1270 "Tomelilla"       216  5.375278 15727.272 9.663152
1975 1265 "Sjöbo"           63 4.1431346 15727.272 9.663152
1975 1883 "Karlskoga"      4033  8.302266 15727.272 9.663152
1975 1492 "Åmål"          104  4.644391 15727.272 9.663152
1975  184 "Solna"          4619  8.437934 15727.272 9.663152
1975 1083 "Sölvesborg"     918  6.822197 15727.272 9.663152
1975  330 "Knivsta"           .         . 15727.272 9.663152
1975  125 "Ekerö"          337  5.820083 15727.272 9.663152
1975  643 "Habo"            247  5.509388 15727.272 9.663152
1975 2463 "Åsele"          168  5.123964 15727.272 9.663152
1975  486 "Strängnäs"    1101  7.003974 15727.272 9.663152
1975 2180 "Gävle"        12737  9.452267 15727.272 9.663152
1975 1275 "Perstorp"        629  6.444131 15727.272 9.663152
1975 1445 "Essunga"         223  5.407172 15727.272 9.663152
1975 2583 "Haparanda"         0         . 15727.272 9.663152
1975 1961 "Hallstahammar"  3185  8.066208 15727.272 9.663152
1975  163 "Sollentuna"     5317  8.578665 15727.272 9.663152
1975 1440 "Ale"            1311  7.178545 15727.272 9.663152
1975  781 "Ljungby"         805  6.690842 15727.272 9.663152
1975 2560 "Älvsbyn"        479    6.1717 15727.272 9.663152
1975  123 "Järfälla"     4311  8.368925 15727.272 9.663152
1975 2082 "Säter"          736   6.60123 15727.272 9.663152
1975  683 "Värnamo"       1764  7.475339 15727.272 9.663152
1975  586 "Mjölby"        2109  7.653969 15727.272 9.663152
1975  428 "Vingåker"       879  6.778785 15727.272 9.663152
1975 2034 "Orsa"            517  6.248043 15727.272 9.663152
1975 1446 "Karlsborg"       385  5.953243 15727.272 9.663152
1975 2132 "Nordanstig"      282  5.641907 15727.272 9.663152
1975  882 "Oskarshamn"     2569  7.851272 15727.272 9.663152
1975 1880 "Örebro"       19444  9.875294 15727.272 9.663152
1975  562 "Finspång"      2418  7.790696 15727.272 9.663152
1975  686 "Eksjö"         1239   7.12206 15727.272 9.663152
1975  126 "Huddinge"      12468  9.430921 15727.272 9.663152
1975 1780 "Karlstad"       8567  9.055673 15727.272 9.663152
1975  461 "Gnesta"            0         . 15727.272 9.663152
1975 2481 "Lycksele"        748  6.617403 15727.272 9.663152
1975 1282 "Landskrona"     4283  8.362409 15727.272 9.663152
1975 1415 "Stenungsund"    1313   7.18007 15727.272 9.663152
1975 2418 "Malå"           177   5.17615 15727.272 9.663152
1975  860 "Hultsfred"      1684  7.428927 15727.272 9.663152
1975 1864 "Ljusnarsberg"    346  5.846439 15727.272 9.663152
1975 1060 "Olofström"     2154  7.675082 15727.272 9.663152
1975 2021 "Vansbro"         450  6.109248 15727.272 9.663152
1975 2404 "Vindeln"           0         . 15727.272 9.663152
1975 1499 "Falköping"     1612  7.385231 15727.272 9.663152
1975 1493 "Mariestad"      1432  7.266828 15727.272 9.663152
1975 1419 "Tjörn"          107 4.6728287 15727.272 9.663152
1975 1443 "Bollebygd"         .         . 15727.272 9.663152
1975 1984 "Arboga"            2  .6931472 15727.272 9.663152
1975 1283 "Helsingborg"    7919   8.97702 15727.272 9.663152
1975 1461 "Mellerud"        261   5.56452 15727.272 9.663152
1975 1463 "Mark"           1950  7.575585 15727.272 9.663152
1975 2580 "Luleå"         8318  9.026177 15727.272 9.663152
1975 1291 "Simrishamn"      743  6.610696 15727.272 9.663152
1975 1315 "Hylte"           359  5.883322 15727.272 9.663152
1975 2462 "Vilhelmina"      507  6.228511 15727.272 9.663152
1975 2023 "Malung"          601  6.398595 15727.272 9.663152
1975 2031 "Rättvik"        236  5.463832 15727.272 9.663152
1975  767 "Markaryd"        893  6.794587 15727.272 9.663152
1975 2581 "Piteå"         2159  7.677401 15727.272 9.663152
1975 2521 "Pajala"            0         . 15727.272 9.663152
1975 1480 "Göteborg"     74253 11.215234 15727.272 9.663152
1975 1272 "Bromölla"       370  5.913503 15727.272 9.663152
1975 1230 "Staffanstorp"    588  6.376727 15727.272 9.663152
end
I deeply appreciate any help!

Best,
Mikaela