Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Foreach with lmdi command

    The following is an extract from my database:

    Code:
    Country FAO Year    Wfp        Population        GdpPc                  Tecn
    "Armenia" 1 1993  1170731343.096  3363108  3249.400252497095  .10713052212720128
    "Armenia" 1 1994  1159436284.963  3283667  2761.805508711754  .12784822054656447
    "Armenia" 1 1995  1092693493.016  3217348  2961.602493536602  .11467626815183306
    "Albania" 3 1993    1555048044.9  3195199 2942.5482868985623   .1653949715359761
    "Albania" 3 1994  1584927885.346  3146519  3590.856512287865   .1402752645812008
    "Albania" 3 1995   1445006270.68  3112936  3920.170301545711   .1184116971036939
    "Algeria" 4 1993 13758430747.674 27635515  8318.869193318815 .059846264055076474
    "Algeria" 4 1994 11166499972.783 28213774  8013.726513510741 .049387991977610325
    "Algeria" 4 1995 16001000023.852 28757785  8151.331348189717   .0682595067936646
    In my real database, the countries are 121.
    I would like to run the following command in a loop for every level of FAOcode (i.e. for each Country)
    Code:
     lmdi Wfp = Population GdpPc Tecn, t(Year) over(FAOcode)
    so that I won't have to run the command for every single country one by one.

    I tried with:
    Code:
     levelsof FAOcode, local(levels)
    foreach l of local levels {
     lmdi Wfp = Population GdpPc TecnologiaWfp, t(Year) over(FAOcode)  
     }
    but it gives me an error.

    Thank you for any help you can give me!
    Last edited by Tommaso Felici; 12 Jul 2022, 08:17.

  • #2
    I don't understand the problem. Where's the `l' macro?

    Comment


    • #3
      Originally posted by Jared Greathouse View Post
      I don't understand the problem. Where's the `l' macro?
      Probably this is my error...! Can you suggest to me a way to put the command ldmi in a foreach loop?

      Comment


      • #4
        I've never heard of this command. And, its syntax looks illegal. Is it user written?

        Comment


        • #5
          Code:
          search lmdi
          shows that this is a command from SSC. It doesn't support if so you need some kind of work-around.

          The loop in #1 just repeats the same command again and again -- so the unstated error may be that the command fails second time around the loop as the variables generated already exist.


          If you don't get better answers, you should perhaps approach the program author for support.




          Comment

          Working...
          X