Announcement

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

  • varlist required though already specified

    Hi everyone,

    I wonder where the error is in the following code:


    local ivs trustmean C02_SQ001 C03 C04_SQ001

    local cvs gender age1 age2 age3 age4

    foreach IV of varlist `ivs' {
    reg D04_SQ001 `cvs' `IV'
    estat ic
    }
    varlist required
    r(100);


    Any comment is highly appreciated! Thanks!

    Regards,
    Filip




  • #2
    The most likely explanation for this is that you are issuing commands one by one from a file in the do-file editor. When that happens, local macros defined in one statement are not visible to another statement. That is what local means: the scope of a local definition is as small as one statement if that one statement is run by itself by a file.

    The test of this is that if you run all these commands together, they should work.

    Alternatively, people sometimes overdo the definition of locals. This would be fine style:

    Code:
    foreach IV in trustmean C02_SQ001 C03 C04_SQ001 { 
        reg D04_SQ001 gender age1 age2 age3 age4 `IV'
        estat ic
    }

    Comment


    • #3
      Thank you very much, Nick! The local issues seemed to be the problem.

      Comment


      • #4
        Hi I'm having a similar issue. I'm using Stata IC 11. I run the following commands from a single do file.

        var lnd4 lndzl, lags(1/3)
        varlmar, mlag(3)
        And I receive the following error

        varlmar, mlag(3)
        varlist required
        r(100);
        I receive this error regardless of whether I use the do file or not.

        Comment


        • #5
          I'd put

          Code:
          set trace on 
          set traced 1
          before you call varlmar so that you and we can see where the error occurs. It's also possible that we can't understand the problem because it's specific to your data. See FAQ Advice #12 on giving a data example.

          In your previous thread https://www.statalist.org/forums/for...otstrap-saving Carlo Lazzaro alerted you to the request to use real given and family names, and that request still stands.

          Comment


          • #6
            Originally posted by Nick Cox View Post
            I'd put

            Code:
            set trace on
            set traced 1
            before you call varlmar so that you and we can see where the error occurs. It's also possible that we can't understand the problem because it's specific to your data. See FAQ Advice #12 on giving a data example.

            In your previous thread https://www.statalist.org/forums/for...otstrap-saving Carlo Lazzaro alerted you to the request to use real given and family names, and that request still stands.
            Nick I would rather not use my real name. Given how sensitive personal information is on the internet, I'll opt to remain anonymous. Thank you for understanding.

            Comment


            • #7
              I understand, and I hope you understand that some of us, who are subject to the same pressures of the internet that you are, but choose to use our easily-traceable names to participate in Statalist and to help ensure it remains a polite and professional forum, may choose to bypass postings from those who instead choose the shield of anonymity.

              Comment


              • #8
                Originally posted by William Lisowski View Post
                I understand, and I hope you understand that some of us, who are subject to the same pressures of the internet that you are, but choose to use our easily-traceable names to participate in Statalist and to help ensure it remains a polite and professional forum, may choose to bypass postings from those who instead choose the shield of anonymity.
                I'm sorry if I was impolite or unprofessional. Other forums such as Eviews are very courteous and professional yet they don't require to disclose names. Besides I could just provide a fake name, so what is the point? It just seems snobbish to say that you refuse to reply to inquiries unless a full name is supplied, whether or not that name is real.

                Comment


                • #9
                  Every community has its own customs and values. The norm here on Statalist is to use our real first and last names. I do not doubt that some of the names shown are fake--I even know it for a fact in a few cases. There is no enforcement mechanism, except that some of us will not respond to a request from an evidently unreal name, or one we know to be unreal (or at least not after the person has been explicitly reminded of the norm being broken).

                  But I want to emphasize the values that this norm exists to preserve:

                  1. It is sometimes said that the test of character is what one does when nobody is looking. It is similar when one is acting anonymously or pseudonomously on the Internet, and I'm sure I don't have to tell you what a cesspool much of that turns out to be. When we use our real names we hold ourselves publicly accountable to be courteous, collegial, and professional here.

                  2. "Given how sensitive personal information is on the internet, I'll opt to remain anonymous. " Actually, I don't understand the relevance of this at all. Nobody is asking you to divulge anything sensitive here: we don't ask for your job title or geographic location--unless you choose to give it. Just your real name. So what is sensitive? You might look "foolish" for having asked a "silly" question? Or just for even having asked for help at all? If that's the concern, then Statalist is probably not a good environment for you. While we are courteous, collegial, and professional here, we are also brutally frank. In this community it is understood that we all have some areas of knowledge we can share, and we all have areas where we are ignorant and need help from others. It is understood that we all make mistakes, and that the solution to mistakes is to get them corrected and learn from them. I am one of the most active members of Statalist; I post many times most days. I would guess that I make 2 or 3 errors in my posts in an average day--and somebody publicly corrects me (or I publicly correct them myself if I realize them subsequently). I am constantly correcting errors in other people's code or narratives as well--that is what they want; that is why they come here. That is a good thing! I learn from it, as does everybody reading along (and I have a fairly large number of people who "follow" me here.) If you are not willing to show and take public responsibility for your mistakes or areas of lack of knowledge, this may not be the right community for you. As you point out, there are alternatives where you might fit in better and feel more comfortable.

                  Moreover, there is a benefit from receiving advice from identified sources. If you get help here and incorporate it into your work, and somebody later on asks you where you got that idea from (perhaps because that someone has concerns about it), you will look foolish if all you can say is that you got it from "datawhiz2018"* on Statalist. If you get it from a named person, say, me, for example, then anyone with concerns can check out who I am, find my publications, etc. to get a sense of whether I'm somebody who knows what he's talking about or not.

                  So those are the values and reasons behind this norm. To some of us, this is very important.

                  *Hat tip to a StataCorp employee (which one, I cannot remember) who brought up this point using this example or one very similar in an earlier discussion of this issue.

                  Comment


                  • #10
                    You were neither impolite nor unprofessional. My intent was only to let you know that your choice to flaunt an obvious false name has a consequence you may not have considered.

                    Comment


                    • #11
                      William and Clyde put it very well. We don't tell other forums what they should do, but a tradition of names has worked well on Statalist for 24 years now.

                      Comment

                      Working...
                      X