Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9183239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:45:15+00:00 2026-06-17T18:45:15+00:00

My first question is simple, but cannot find any answer anywhere and it’s driving

  • 0

My first question is simple, but cannot find any answer anywhere and it’s driving me crazy:

  • When defining a local list in Stata how do I do a carriage return if the list is really long?

The usual /// doesn’t work when inside double quotations marks.

For example, this doesn’t work:

local reglist "lcostcrp lacres lrain ltmax ///
ltmin lrainsq lpkgmaiz lwage2 hyb gend leducavg ///
lageavg ldextn lfertskm ldtmroad"

It does work when I remove the quotation marks, but I am warned that I should include the quotations.

My second question is a more serious problem:

  • Having defined the local reglist, how can I get Stata to remember it for multiple subsequent uses (that is, not just one)?

For example:

local reglist lcostcrp lacres lrain ltmax ///
ltmin lrainsq ///
lpkgmaiz lwage2 ///
hyb gend leducavg lageavg ldextn lfertskm ldtmroad

reg lrevcrp `reglist' if lrevcrp~=.,r
mat brev=e(b)
mat lis brev

/*Here I have to define the local list again.  How do I get Stata to remember 
it from the first time ??? */

local reglist lcostcrp lacres lrain ltmax ///
ltmin lrainsq ///
lpkgmaiz lwage2 ///
hyb gend leducavg lageavg ldextn lfertskm ldtmroad

quietly tabstat `reglist' if lrevcrp~=., save
mat Xrev=r(StatTotal),1
mat lis Xrev

Here, I define the local reglist, then run a regression using this list and do some other stuff.

Then, when I want to get the means of all the variables in the local reglist, Stata doesn’t remember it anymore and have to define it again. This defeats the whole purpose of defining a list.

I would appreciate it if someone could show me how to define a list just once and be able to call it as many times as one likes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:45:16+00:00Added an answer on June 17, 2026 at 6:45 pm

    The best answer to your first question is that if you are typing a long local definition in a command, then (1) you don’t need to type a carriage return, you just keep on typing and Stata will wrap around and/or (2) there is a better way to approach local definition. I wouldn’t usually type long local definitions interactively because that is too tedious and error-prone.

    The quotation marks are not essential for examples like yours, only essential for indicating strings with opening or closing spaces.

    Your second question is mysterious. Stata won’t forget definitions of local macros in the same program (wide sense) unless you explicitly blank out that macro, i.e. redefine it to an empty string. Here program (wide sense) means program (narrow sense), do-file, do-file editor contents, or main interactive session. You haven’t explained why you think this happens. I suspect that you are doing something else, such as writing some of your code in the do-file editor and running that in combination with writing commands interactively via the command window. That runs into the difficulty alluded to: local macros are local to the program they are defined in, so (in the same example) macros defined in the do-file editor are local to that environment but invisible to the main interactive session, and vice versa.

    I suggest that you try to provide an example of Stata forgetting a local macro definition that we can test for ourselves, but I am confident that you won’t be able to do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple question but cannot find a simple answer. I have
Simply straightforward question, but one for which I cannot find any suggestions. Supported HTML5
I have been looking around for an answer to my question but couldn't find
I have one obviously simple problem, but cannot find good solution, so I would
I imagine this question has been asked and answered, but I cannot find it.
I have a question that's so simple I cannot believe I can't answer it
Just a simple question since I cannot find the correct url on the Jboss
this is my first question on here. The question is simple - # this
First, the simple question. Is it possible to receive an event when MEF (System.ComponentModel.Composition)
This is just a simple question. Either way works. I prefer my first example,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.