Dear Statalisters,
I have a classroom dataset of four variables- the first is the name of the child (c_name) and the next three (c_1, c_2, c_3) are the names of the children chosen by the child in the first column. I want to generate a variable that counts the number of times every child is chosen by the other children. For every c_name, I want to count through all the observations in c_1, c_2, c_3 and generate a count variable. Here is a sample of my data. Appreciate your help. Thank you.
I have a classroom dataset of four variables- the first is the name of the child (c_name) and the next three (c_1, c_2, c_3) are the names of the children chosen by the child in the first column. I want to generate a variable that counts the number of times every child is chosen by the other children. For every c_name, I want to count through all the observations in c_1, c_2, c_3 and generate a count variable. Here is a sample of my data. Appreciate your help. Thank you.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str18 c_name str17(c_1 c_2) str18 c_3 "Bhawani" "Aithal Vishruth" "Gowda Dhaiwik .M" "P. Pravith" "Sirishree" "Sankarshan .AA" "Hegde Shoorthi" "R.Rishika" "Thrisha" "Sirishree" "Hegde Shoorthi" "P. Pravith" "Sankarshan .AA" "Jaya Mohan Aneesh" "Jonna Victoria. A" "Modak .M" "Jonna Victoria. A" "Sirishree" "Thrisha" "S.Lavanya" "B.R.Brunda" "Sirishree" "Hegde Shoorthi" "R.Rishika" "Alur Akshata" "Hegde Shoorthi" "Kashyap Amrutha" "R. Saanvi" "Aithal Vishruth" "Gowda Dhaiwik .M" "P. Pravith" "S. Hemanth Kumar" "B.Y. Sujan" "Aithal Vishruth" "J.S. Dhwani" "Rao Gorakshith .D" "Babu Mukul .CS" "Aithal Vishruth" "Modak .M" "P. Pravith" "D.Poorvaja" "Kashyap Amrutha" "R.Rishika" "R. Saanvi" "Donthi Ahan .N" "Aithal Vishruth" "Gowda Dhaiwik .M" "Rao Gorakshith .D" "Gowda Dhaiwik .M" "Aithal Vishruth" "P. Pravith" "S. Hemanth Kumar" "Guru Raj Parnika" "Hegde Shoorthi" "Kashyap Amrutha" "R. Saanvi" "Hegde Shoorthi" "Sirishree" "R.Rishika" "S.G. Ahana" "J.S. Dhwani" "Sankarshan .AA" "Hegde Shoorthi" "R.Rishika" "Jaya Mohan Aneesh" "Thrisha" "Sankarshan .AA" "Jois Prathyush .V" "Jois Prathyush .V" "Sirishree" "Hegde Shoorthi" "R.Rishika" "" "Alur Akshata" "D.Poorvaja" "R. Saanvi" "Modak .M" "Sankarshan .AA" "Aithal Vishruth" "P. Pravith" end
Comment