Announcement

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

  • Do-file seems to run well, but doesn't really execute commands

    Dear all,

    I have a very simple do-file with a few commands. When running this do-file as a whole everything seems to be going fine: all commands run smoothly and the output I get is the one I expect. Yet, when checking my data, I see that some commands, like replace, have not been really executed.
    eg.
    When I run the do-file with (among others) these commands:
    list EnumID VilID HHID ID_entrant aq1 if EnumID == 5 & HHID == 22
    replace HHID = 2 if EnumID == 5 & HHID == 22 & aq1 == "BUTYOKA"
    list EnumID VilID HHID aq1 ID_entrant if EnumID == 5 & HHID == 2


    Then I get the following response

    which seems fine.

    Yet, when I then copy paste the following line from my do-file into the command box
    list EnumID VilID HHID aq1 ID_entrant if EnumID == 5 & HHID == 2

    then I get the following response, which is indicating that my data were not really changed...



    Can anybody explain what is the problem here? What am I doing wrong? I have added my log file as an attachment.

    Thank you,

    Kewan Mertens
    Attached Files

  • #2
    I don't see your last command in your log file (launch the do-file without the log close, then run the command line directly from the command box, and then close log from command box).
    I'd like to see whether the two outputs really comes from the same dataset.

    Actually, the data seems to be manipulated beetween the two command you wrote, as the position (line of observation) changes from 142 to 97...

    Comment


    • #3
      The Forum FAQ recommends that you report exactly what you typed into Stata and exactly what you got back from Stata using CODE delimiters -- as described in the FAQ. Photos are not as legible, nor can readers cut/paste etc. In your SMCL file, you have

      Code:
      . list EnumID VilID HHID aq1 if EnumID == 1 & HHID == 21
           +------------------------------------+
           | EnumID   VilID   HHID          aq1 |
           |------------------------------------|
       21. |      1      22     21   BUGHENDERO |
       23. |      1      24     21     BUTHONYO |
           +------------------------------------+
      .
      . list EnumID VilID HHID ID_entrant aq1 if EnumID == 5 & HHID == 2
           +--------------------------------------------+
           | EnumID   VilID   HHID   ID_ent~t       aq1 |
           |--------------------------------------------|
      142. |      5       2      2         26   BUTYOKA |
           +--------------------------------------------+
      
      . replace  HHID = 2 if EnumID == 5 & HHID == 22 & aq1 == "BUTYOKA"
      (1 real change made)
      
      . list EnumID VilID HHID aq1 ID_entrant if EnumID == 5 & HHID == 2
           +--------------------------------------------+
           | EnumID   VilID   HHID       aq1   ID_ent~t |
           |--------------------------------------------|
      142. |      5       2      2   BUTYOKA         26 |
      143. |      5       2      2   BUTYOKA         27 |
           +--------------------------------------------+
      At first glance (and without seeing all your data), the results are possible. The first list refers to HHID == 21, whereas your replace command refers to HHID == 22. What precisely are you trying to achieve?

      Comment


      • #4
        Dear Stephen and Charlie,

        Thank you for your fast reply. I apologize for the lack of clarity. The problem has been solved by one of my colleagues though. The problem was that somewhere in my do-file I had 'preserve' without it being followed by 'restore', so all changes being made after this 'preserve' were not kept (even if I saved the file after the changes).

        Thank you,

        Kind regards

        Kewan Mertens

        Comment

        Working...
        X