Announcement

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

  • replacement for old "for any" command

    Hi,
    I was curious to know if there is a more recent equivalent for the "old" stata 7 command "for any". I am still using "for any" to loop "in parallel": for instance, replacing a list of name by another list of names, like in the following example:

    for any A B C / any 1 2 3 : replace var=Y if var==X

    which is going to run : var=1 if var=A, then replace var=2 if var=B ...


    This command is fine but has several drawbacks (especially when your name containt X and Y): Do you have suggestion to do a similar routine with a more up-to-date line of command?


    Thanks very much

    Adrien


  • #2
    There's an FAQ on looping over parallel lists: http://www.stata.com/support/faqs/pr...arallel-lists/

    Comment


    • #3
      Hi everyone,
      Please, I need to generate a variable the number of years a firm had participated in collaborative agreements from year 2008 to year 2012

      Comment


      • #4
        See also http://www.stata.com/statalist/archi.../msg00258.html and the other messages referenced there for an alternative approach based on nested lists.

        Comment


        • #5

          Thank you for your answer, I am using stata 10, and I would like grafing the interaction effect, please can anyone help me with the commond bacause margins not work in stata10

          Comment


          • #6
            HANA: Please

            1. Start a new thread if you have a new question.

            2. Ask more specific questions.

            3. Use full real names as requested in the Statalist FAQ Advice. The Advice should help also with #2.

            Comment


            • #7
              Also, it is a good idea to only ask the same question in one thread as opposed to asking it in several. Besides distracting from the main topic, the risk you run when you ask unrelated questions is that the people who may know the answer to your question may not be reading the current thread because it doesn't interest them.
              -------------------------------------------
              Richard Williams, Notre Dame Dept of Sociology
              Stata Version: 17.0 MP (2 processor)

              EMAIL: [email protected]
              WWW: https://www3.nd.edu/~rwilliam

              Comment


              • #8
                Code:
                for any A B C / any 1 2 3 : replace var=Y if var==X
                


                presupposes that A, B, C are names of numeric variables or scalars. True or false?



                Comment

                Working...
                X