Announcement

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

  • varlist or statlist required

    Hello,
    I would like to make a graph with a variable and several options, but I get this error message; "varlist or statlist required".

    For example several answer options in one question.

    . graph bar, over ( e13)
    varlist or statlist required
    r(198);


    Can anyone help me?

    Thanks a lot

    Lucia

    En français:

    Bonjour,
    J'aimerai faire un graph avec une variable et plusieurs options, mais j'obtiens ce message d'erreurs ; "varlist or statlist required".


    Par exemple plusieurs options de réponses dans une question.


    . graph bar, over ( e13)
    varlist or statlist required
    r(198);



    Quelqu'un pourrais-il m'aider ?

    Merci beaucoup

    Lucia

  • #2
    Lucia:
    welcome to this forum.
    A trivial issue indeed:
    -graph bar- needs a variable to make the option -over()- work out properly, as in the following toy-example:
    Code:
    . use "https://www.stata-press.com/data/r17/nlswork.dta"
    (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
    . graph bar age, over (year)
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      You have to tell Stata what the height of the bars is supposed to represent. Maybe you want:

      Code:
      sysuse auto, clear
      graph bar (count), over(rep78)
      or
      Code:
      graph bar (percent) , over(rep78)
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        Hello, Thank you very much for your reply. Here is another problem:


        . sysuse auto, clear
        (1978 Automobile Data)

        .
        . graph bar (count), over(rep78)
        varlist required
        r(100);


        Thank you for your help
        Lucia

        Comment


        • #5
          Seems like you are using a very old version of Stata (version 12 or older). You need to tell us that. If you don't, then we need to make an assumption. The default assumption on this list is that if you don't tell us, then you have the latest version.

          The following should work in your version

          Code:
          sysuse auto
          gen count = 1 if !missing(rep78)
          graph bar (count) count, over(rep78)
          ---------------------------------
          Maarten L. Buis
          University of Konstanz
          Department of history and sociology
          box 40
          78457 Konstanz
          Germany
          http://www.maartenbuis.nl
          ---------------------------------

          Comment


          • #6
            Which version of Stata are you using? This syntax was, IIRC, introduced in the lifetime of Stata 13 and so is not supported in Stata 12 or earlier.

            See also the request to flag use of an out-of-date version https://www.statalist.org/forums/help#version



            Comment


            • #7
              Bonjour,
              merci beaucoup pour votre réponse.
              En effet j'ai une ancienne version stata (Stata IC12.1).
              Avec les conseils de Maarten Buis, cela a bien fonctionné.
              Je dois maintenant créer des barres de graphique empilées. Je vais essayer, mais si vous avez des conseils. J'accepterai avec plaisir.
              Lucie

              Comment


              • #8
                This should also work in Stata 8 up, provided you can install from SSC

                Code:
                sysuse auto, clear
                
                ssc install catplot
                
                catplot rep78, recast(bar)

                Comment


                • #9
                  Dear Nick,
                  It works very well, thank you
                  Lucia

                  Comment


                  • #10
                    C'est bien.

                    Comment

                    Working...
                    X