I have a datasets which looks like this:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str40 countryname str6 timeperiod double(FDI_L FDI_A) "United States" "2019Q1" 1.0097e+11 -4.177e+09 "United States" "2019Q2" 9.6438e+10 9.6351e+10 "United States" "2019Q3" 7.0398e+10 1.4781e+10 "United States" "2019Q4" 3.4393e+10 1.5236e+10 "United States" "2020Q1" 4.5721e+10 3.6218e+10 "United States" "2020Q2" -4.6176e+10 7.7625e+10 "United States" "2020Q3" 1.13969e+11 1.32672e+11 "United States" "2020Q4" 9.7784e+10 6.5177e+10 "United States" "2021Q1" 6.4348e+10 8.4679e+10 "United Kingdom" "2019Q1" -15202459435 -3979674150 "United Kingdom" "2019Q2" 23555299952 -832815057.2 "United Kingdom" "2019Q3" 30061488762 -73945938.25 "United Kingdom" "2019Q4" -36177653821 -43345435205 "United Kingdom" "2020Q1" 17501964977 -2883293879 "United Kingdom" "2020Q2" 5154293949 -2515712457 "United Kingdom" "2020Q3" -933939859.9 -7339759729 "United Kingdom" "2020Q4" -3649545636 -22597132512 "United Kingdom" "2021Q1" 16490163779 5476504279 "Austria" "2019Q1" 3041595886 2068239771 "Austria" "2019Q2" 4394790700 7811962400 "Austria" "2019Q3" 11561977327 13096457873 "Austria" "2019Q4" -27098639681 -23666610306 "Austria" "2020Q1" -273459912.5 2177755352 "Austria" "2020Q2" -4163340774 -5558830923 "Austria" "2020Q3" -14997123076 -7167759836 "Austria" "2020Q4" -7577291028 -4224053452 "Austria" "2021Q1" 666280733.3 1237378505 "Belgium" "2019Q1" -11188484343 1345889143 "Belgium" "2019Q2" -41030781800 -41676909300 "Belgium" "2019Q3" 16530136079 9045651621 "Belgium" "2019Q4" 6723456256 1301956950 "Belgium" "2020Q1" 2982697836 5748171467 "Belgium" "2020Q2" -23447979297 -17435366258 "Belgium" "2020Q3" -8122759802 -10377588361 "Belgium" "2020Q4" 3293592652 -2039856369 "Denmark" "2019Q1" -14577633607 -13769083747 "Denmark" "2019Q2" 332105597.8 3744091667 "Denmark" "2019Q3" 5949400795 10158483452 "Denmark" "2019Q4" 4776276940 6258176353 "Denmark" "2020Q1" -492070312.2 2472446815 "Denmark" "2020Q2" 1249899397 2995362071 "Denmark" "2020Q3" 3717459562 2826921262 "Denmark" "2020Q4" 734916529 5001052518 "Denmark" "2021Q1" 742658708.5 3950905429 "France" "2019Q1" 15830382171 21788525509 "France" "2019Q2" 20340430810 18706458640 "France" "2019Q3" 7317804288 11874544343 "France" "2019Q4" 13994155132 10654347708 "France" "2020Q1" -23800164473 13563170596 "France" "2020Q2" 3209957765 -2448330743 "France" "2020Q3" 11875430411 15043762609 "France" "2020Q4" 21957324112 27398133995 "France" "2021Q1" 6413885815 13736226735 "Germany" "2019Q1" 20112240457 62983068800 "Germany" "2019Q2" 26210302500 40474550300 "Germany" "2019Q3" 25236645261 16595740682 "Germany" "2019Q4" -3940191144 33094727131 "Germany" "2020Q1" 30479753634 52720424744 "Germany" "2020Q2" 2669824877 -11128675974 "Germany" "2020Q3" 30970286508 17621327386 "Germany" "2020Q4" 48497286954 52270424788 "Germany" "2021Q1" 17283539095 54841049076 "Italy" "2019Q1" 12711553829 14947887771 "Italy" "2019Q2" 897836300 1448449300 "Italy" "2019Q3" 13099793700 11984515448 "Italy" "2019Q4" 4476030569 4488208738 "Italy" "2020Q1" 3779921694 2523990886 "Italy" "2020Q2" 308395612.9 69389012.9 "Italy" "2020Q3" 2033904455 8397453794 "Italy" "2020Q4" -12569571089 -6225737071 "Italy" "2021Q1" 6978477410 8174891095 "Luxembourg" "2019Q1" 48004461868 58791776952 "Luxembourg" "2019Q2" -1.09389e+11 -91133676173 "Luxembourg" "2019Q3" -37575105580 -77324603037 "Luxembourg" "2019Q4" -2.65494e+11 -2.90269e+11 "Luxembourg" "2020Q1" -94299954844 -1.20678e+11 "Luxembourg" "2020Q2" 15527184830 -32666246423 "Luxembourg" "2020Q3" -58745315507 -16270518866 "Luxembourg" "2020Q4" -39469639299 -25993368804 "Luxembourg" "2021Q1" -7106003279 -1505726469 "Netherlands, The" "2019Q1" 8368363886 55469940800 "Netherlands, The" "2019Q2" -2.05551e+11 -2.36469e+11 "Netherlands, The" "2019Q3" 85255961494 1.13109e+11 "Netherlands, The" "2019Q4" -57371352981 -58542671394 "Netherlands, The" "2020Q1" -80644210325 -40709139152 "Netherlands, The" "2020Q2" -41551903187 7766062381 "Netherlands, The" "2020Q3" 19891351783 18988952795 "Netherlands, The" "2020Q4" -47016899963 -1.86275e+11 "Netherlands, The" "2021Q1" 23192111819 56827842800 "Norway" "2019Q1" 1928721337 -1218422075 "Norway" "2019Q2" -5717810332 1866383963 "Norway" "2019Q3" 5576795788 1240503949 "Norway" "2019Q4" 15268288222 6299012436 "Norway" "2020Q1" -1869044273 -2089142656 "Norway" "2020Q2" -2887325349 -2145708583 "Norway" "2020Q3" 1251369113 1378203724 "Norway" "2020Q4" -1420790251 -3181905465 "Norway" "2021Q1" 260313111.5 3214637965 "Sweden" "2019Q1" 5572534593 8545249296 "Sweden" "2019Q2" 2185988185 7411731811 end
For some countries, I have observations up to 2021Q1 while for other observations stop earlier. I would like to delete the countries which do not have the most up to date observations. In the example above it would be Belgium and Sweden.
I would be updating this database on a regular basis and I am looking to some sort of loop that would automatically delete the countries which do not have the full time period.
How to go about it?
Thanks very much for your help and many apologies if this is a silly questions to some of the experts on this forum.
0 Response to Deleting some observations within a variable when conditions are met
Post a Comment