Announcement

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

  • Loop over loop for multiple cross-tabulations

    Hi,

    I have a set of column and row variables to make cross-tables. I came across a post that asked a similar question using double loops, but not helping with my case: https://www.stata.com/statalist/arch.../msg00074.html

    My goal is to make cross-tabs of all combinations of column and row variables i.e. aa vs xx, aa vs yy, bb vs xx, bb yy. and store them in a single table in separate columns using the asdoc package (ssc). The method I tried is using row variables as columns sometimes (e.g. xx vs aa), which I don't want:

    foreach v of varlist aa bb {
    asdoc tab xx yy `v', col chi
    }

    Please let me know if this is possible to do.

    Thanks in advance!

  • #2
    I don't know anything about using asdoc (from SSC, as you are asked to explain). But if I understand this correctly you need nested loops

    Code:
    foreach x in aa bb { 
         foreach y in xx yy { 
               tab `x' `y', col chi 
         }
    }

    Comment


    • #3
      Sonnen Blume : I don't know if you have ever been asked to use your real name as requested for members of the Forum.

      Although you are a member of this Forum since several years and have posted many posts, I nevertheless think that you should consider to use your real name -- the reasons are explained here and here here (at #3). The high quality of this Forum in no small part dependent on the willingness of its members to follow its rules and I fully support Nick Cox in repeatedly requesting the use of real names.

      It is not entirely impossible that Sonnen Blume is your real name (translating from German would be equivalent to the name Sun Flower): Then its fine and you can explain it here to avoid further requests of this sort. But otherwise, please show your appreciation (or reverence for) this Forum by changing the name to your real name.

      Comment


      • #4
        Originally posted by Dirk Enzmann View Post
        Sonnen Blume : I don't know if you have ever been asked to use your real name as requested for members of the Forum.

        Although you are a member of this Forum since several years and have posted many posts, I nevertheless think that you should consider to use your real name -- the reasons are explained here and here here (at #3). The high quality of this Forum in no small part dependent on the willingness of its members to follow its rules and I fully support Nick Cox in repeatedly requesting the use of real names.

        It is not entirely impossible that Sonnen Blume is your real name (translating from German would be equivalent to the name Sun Flower): Then its fine and you can explain it here to avoid further requests of this sort. But otherwise, please show your appreciation (or reverence for) this Forum by changing the name to your real name.
        Hi Dirk, thanks for your suggestion. Sonnen Blume is the translation of my Sanskrit for my name (सूर्यकमल) that I learned from my German teacher.

        Comment


        • #5
          Originally posted by Nick Cox View Post
          I don't know anything about using asdoc (from SSC, as you are asked to explain). But if I understand this correctly you need nested loops

          Code:
          foreach x in aa bb {
          foreach y in xx yy {
          tab `x' `y', col chi
          }
          }
          Thanks Nick! It is neatly done as always.
          Last edited by Sonnen Blume; 29 Feb 2024, 18:04.

          Comment


          • #6
            Sonnen Blume : I understand: You are not using your real name in an English transcription (would it be Soory Kamal?) but did translate your name into German (and I tried to translate it into English as Sun Flower).

            This reminds me of the famous traveling of a well known German poem ("Wanderers Nachtlied" by Goethe) from German into Japanese into French back into German whereby the final product of these "Chinese whispers" did end up in a completely new poem. If you are interested and can read German see p. 26 in

            Hijiya-Kirschnereit, I. (2001). "Stille Post" -- Ein Rundgang. In I. Hijiya-Kirschnereit (Hrsg.), Eine gewisse Farbe der Fremdheit. Aspekte des Übersetzens Japanisch -- Deutsch -- Japanisch (S. 17--43). München: Iudicium-Verlag. [URL: https://perspectivia.net/servlets/MC...rschnereit.pdf]
            Last edited by Dirk Enzmann; 29 Feb 2024, 18:50.

            Comment

            Working...
            X