+ Reply to Thread
Results 1 to 6 of 6

Loop on example on stata command

  1. #1
    Registered User
    Join Date
    05-29-2012
    Location
    EU
    MS-Off Ver
    Excel 2007
    Posts
    17

    Lightbulb Loop on example on stata command

    Dear Colleagues,

    I often make use of loops in Stata. For instance, if I want to generate a set of similar tables for a number of variables I would type:

    Please Login or Register  to view this content.
    It's neat and very simple, put required variable names after the word varlist and introduce them into the loop with use of the `var' keyword.

    I want to do analogous loop in VBA. I will use it to automatically generate a number of PDFs. I would like it to look like that:

    Please Login or Register  to view this content.
    What I missing is a loop component where I could substitute different text strings for the variable_name. I will appreciate any help on that.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Loop on example on stata command

    I'm not sure it is exactly what you want but it should be a good starting point:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-29-2012
    Location
    EU
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Loop on example on stata command

    Hi yudlugar,

    Thanks very much for your reply. It looks handy. I hope you don't mind that I am going to ask a wee question - where can I define a sets of text strings that will be substituted for the variable_name? Ideally, I would like to type somewhere in the macro. I have a list of 32 indicators that I will be substituting for the variable_name.

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Loop on example on stata command

    In the example I gave you the text strings would be stored in the range E5:J5. If you wanted to type them in the macro you could use an array like this:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-29-2012
    Location
    EU
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Loop on example on stata command

    Yudlugar,

    again, thanks for your helpful reply. The range in my initial post corresponds to a drop down menu. The menu is available to end-users to "play with" but in the macro I'm using it to insert the indicator name. Number of tables update on change in that field.

  6. #6
    Registered User
    Join Date
    05-29-2012
    Location
    EU
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Loop on example on stata command

    Yudlugar,

    again, thanks for your helpful reply. The range in my initial post corresponds to a drop down menu. The menu is available to end-users to "play with" but in the macro I'm using it to insert the indicator name. Number of tables update on change in that field.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1