Hello,

I am new here and trying to open the topic the right way. I hope I implemented the code correctly and my lack of english is not a problem.

My Stata-Version: 15.1

My problem:

So I have groups (for example 2) within each group are 4 members. Those members chatted in 10 different scenarios (chat1, chat2, chat3...chat10). What I want in the end is the wordcount like this list for every group and every chat:


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float Gruppe byte Number_in_Group float totalwords
1 1  8
1 2 11
1 3  1
1 4 16
end
So as you can see I did this for Group 1 Chat 1. But I need this for:
Group 1 Chat 1
Group 1 Chat 2
Group 2 Chat 1
Group 2 Chat 2....

So I tried this with some loops but didn't get it to work. What I first did:

foreach var of varlist chat1-chat10 {
gen words`var' = wordcount(`var')
}

So I get the wordcount of the chats. But know I need to seperate for every group and chat and delete the "missing observations",

Maybe you can help me with that?

Thank you very much

Maximilian


This is a example of my dataset:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte Number_in_Group str208 chat1 str113 chat2 float Gruppe
1 ""                                 ""                                                                          1
4 ""                                 ""                                                                          1
1 ""                                 ""                                                                          1
1 ""                                 ""                                                                          1
3 ""                                 ""                                                                          1
1 ""                                 ""                                                                          1
4 ""                                 ""                                                                          1
2 ""                                 ""                                                                          1
2 ""                                 ""                                                                          1
2 "1&9?"                             ""                                                                          1
1 "1 und 9?"                         ""                                                                          1
4 "hab ich auch"                     ""                                                                          1
2 "gut"                              ""                                                                          1
3 "jo"                               ""                                                                          1
4 "dann 6"                           ""                                                                          1
4 "und 5"                            ""                                                                          1
2 "ja"                               ""                                                                          1
1 "8 z�hlt nicht, weil Hund?"        ""                                                                          1
2 "denke ich auch"                   ""                                                                          1
4 "geht doch um humanoid doer nicht" ""                                                                          1
4 "hund != humanoid"                 ""                                                                          1
2 "n�chste Seiten 6 und 7?"          ""                                                                          1
2 ""                                 "5?"                                                                        1
3 ""                                 "5"                                                                         1
1 ""                                 "Ist der Panda (2) einer?"                                                  1
2 ""                                 "1 und 7? 7 sieht aber aus wie ein Spielzeug"                               1
4 ""                                 "Spielzeug hei�t ja nicht, dass es keinroboter sein kann"                   1
2 ""                                 "ja ist wahr"                                                               1
2 ""                                 "dann 5�"                                                                   1
4 ""                                 "viel der gezeigten Roboter k�nne auch nicht viel mehr als kommunizieren"   1
1 ""                                 "Ich glaube wir sollten mehr alleine tippen, weil die Zeit recht knapp ist" 1
3 ""                                 "denke ich auch"                                                            1
1 ""                                 ""                                                                          1
1 ""                                 ""                                                                          1
2 ""                                 ""                                                                          1
4 ""                                 ""                                                                          1
4 ""                                 ""                                                                          1
1 ""                                 ""                                                                          1
3 ""                                 ""                                                                          1
4 ""                                 ""                                                                          1
3 ""                                 ""                                                                          1
1 ""                                 ""                                                                          1
4 ""                                 ""                                                                          1
4 ""                                 ""                                                                          1
3 ""                                 ""                                                                          1
2 ""                                 ""                                                                          1
4 ""                                 ""                                                                          1
4 ""                                 ""                                                                          1
2 ""                                 ""                                                                          1
4 ""                                 ""                                                                          1
4 ""                                 ""                                                                          1
1 ""                                 ""                                                                          1
1 ""                                 ""                                                                          1
4 ""                                 ""                                                                          1
1 ""                                 ""                                                                          1
1 ""                                 ""                                                                          1
4 ""                                 ""                                                                          1
4 ""                                 ""                                                                          1
4 "Vorschl�ge?"                      ""                                                                          2
1 ":)"                               ""                                                                          2
1 "1 und 9, der?"                    ""                                                                          2
1 "Oder"                             ""                                                                          2
3 "1 und 9 w�rde ich auch sagen"     ""                                                                          2
2 "Ja"                               ""                                                                          2
4 "dito"                             ""                                                                          2
2 "8?"                               ""                                                                          2
1 "Oh, man muss ja weiter machen"    ""                                                                          2
4 "ist ja tierisch?!"                ""                                                                          2
2 "Stimmt"                           ""                                                                          2
1 "Ich w�rd sagen nein"              ""                                                                          2
2 "dann nur 6"                       ""                                                                          2
4 "1,,5,6 und 7?"                    ""                                                                          2
4 "vll 2?"                           ""                                                                          2
1 ""                                 ""                                                                          2
4 ""                                 ""                                                                          2
4 ""                                 ""                                                                          2
2 ""                                 ""                                                                          3
2 ""                                 ""                                                                          3
1 ""                                 ""                                                                          3
1 ""                                 ""                                                                          3
2 ""                                 ""                                                                          3
1 ""                                 ""                                                                          3
2 ""                                 ""                                                                          3
2 ""                                 ""                                                                          3
1 ""                                 ""                                                                          3
2 ""                                 ""                                                                          3
2 ""                                 ""                                                                          3
2 ""                                 ""                                                                          3
1 ""                                 ""                                                                          3
1 ""                                 ""                                                                          3
2 ""                                 ""                                                                          3
2 ""                                 ""                                                                          3
1 ""                                 ""                                                                          3
2 ""                                 ""                                                                          3
2 "geht los?"                        ""                                                                          3
1 "Yes"                              ""                                                                          3
1 "Hab nur Nr. 1 und 9"              ""                                                                          3
2 "genauso"                          ""                                                                          3
3 "1,9 4??"                          ""                                                                          3
2 "w�rde die Drohne nicht nehmen."   ""                                                                          3
end