Announcement

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

  • resuming a do file after using _request2 then input v1 v2 to establish a data set

    hello statalist. i have a problem with a do file that i am sure will be simple to resolve. But its driving me mad!!!!

    i am using the ralloc add on to create a randomised block trial. The problem isn't with this however (this is just context). The problem is prior to this. I need to set up a data set with 2 columns v1 and v2 where v1 is the strata (1, 2, 3, ....n) and v2 is the number of levels in each stratum.

    So far I have these displays on the screen (see code below). The _request2() causes the do file to stop as required. I then use input v1 v2 typed into the command window, which allows me to populate v1 and v2 in a new data file. I then want the do file to continue with the save command to save the data file I just created.
    After this the ralloc ad on runs fine. The problem is that after the input command, the do file doesn't start again with the 'save' command automatically.
    Does anybody know what's the problem is here?

    di in red "Type this into command window 'input v1 v2'. (in command window): "

    di in red "Type strata number and number of levels (example 1 2, then 2 7 .... after all strata entered type end)'. (in command window): " _request2()


    save "X:\RandomBlockRandomisation\block_setup.dta", replace

    Any ideas on how to sort this will be much appreciated
    Tony

  • #2
    Originally posted by tony fouwather View Post
    The _request2() causes the do file to stop as required.
    How so? I get

    Code:
    . di in red "Type strata number and number of levels (example 1 2, then 2 7 .... after all strata entered type end)'. (in command window): " _request2()
    Type strata number and number of levels (example 1 2, then 2 7 .... after all strata entered type end)'. (in command window): ) invalid name
    r(198);
    and that's not surprising given that _request2() is not documented anywhere in the help file for display.

    It's unclear what the ultimate goal is but display is probably not the best tool. If you want an input statement to create your data, put it directly into the do-file. Creating a dataset manually in the midst a running do-file seems rather arcane to me. What's the anticipated use case for this setup?

    For those who wonder, which is probably most of us, ralloc appears to be from [url="https://www.stata-journal.com/article.html?article=up0023"]SJ[7rl], last updated 16 years ago, and may or may not be relevant to this question.



    Comment


    • #3
      daniel klein _request2() appears to exist but is not documented, and also not undocumented. See this.

      The error above is not because _request2() does not exist, but because it expects a macro name within the parentheses.

      Code:
      . di in red "Type strata number and number of levels (example 1 2, then 2 7 .... after all strata entered type end)'. (in command window): " _request2(_stratas)
      Type strata number and number of levels (example 1 2, then 2 7 .... after all strata entered type end)'. (in command window): .

      Comment


      • #4
        thanks for that.

        i suppose the real question i want to ask is how do you get a do file to resume once its stopped. in my case it stops to input the data. once i have done that i want the do file to resume, saving the data, then carrying on with rest of do file after that.

        so is there a command to add to a do file that makes it resume running

        Comment

        Working...
        X