Dear Stata users,
I have a dataset and a part of it is below:
----------------------- copy starting from the next line -----------------------
[CODE]
* Example generated by -dataex-. For more info, type help dataex
clear
input int redovar str4 astkom2
2000 "1402"
1996 "1480"
1996 "1480"
1997 "0191"
1998 "1283"
1996 "0882"
1997 "0191"
1997 "0680"
1996 ""
1997 "1880"
1996 "1280"
1996 ""
1997 "0191"
1999 "1490"
1997 ""
1996 "1480"
I want to calculate the frequency of unique values of the variable "astkom2" for each year ("redovar" in this case). After that, I want to create a variable and want to store that frequency by year. The levelsof command shows the unique values. But it would be helpful if someone tells how to calculate and store the frequency of unique values as a new variable. As you may see there are some repetition. It is because the data is an individual level data (invidual id is not shown in the above excerpt from the original dataset for simplicity).
Thanks in advance!
Zariab Hossain
Uppsala University
I have a dataset and a part of it is below:
----------------------- copy starting from the next line -----------------------
[CODE]
* Example generated by -dataex-. For more info, type help dataex
clear
input int redovar str4 astkom2
2000 "1402"
1996 "1480"
1996 "1480"
1997 "0191"
1998 "1283"
1996 "0882"
1997 "0191"
1997 "0680"
1996 ""
1997 "1880"
1996 "1280"
1996 ""
1997 "0191"
1999 "1490"
1997 ""
1996 "1480"
I want to calculate the frequency of unique values of the variable "astkom2" for each year ("redovar" in this case). After that, I want to create a variable and want to store that frequency by year. The levelsof command shows the unique values. But it would be helpful if someone tells how to calculate and store the frequency of unique values as a new variable. As you may see there are some repetition. It is because the data is an individual level data (invidual id is not shown in the above excerpt from the original dataset for simplicity).
Thanks in advance!
Zariab Hossain
Uppsala University
Comment