Frequency table with conditions in panel data

1 view (last 30 days)
I have som panel data and with n=6100 T=8, and want to create a simple frequency table.
Basically my data looks something like this:
i date t tobacco expenditure
1.0000 864.0000 1.0000 77.1201
1.0000 871.0000 2.0000 63.7914
1.0000 872.0000 3.0000 60.1131
1.0000 873.0000 4.0000 80.1118
1.0000 874.0000 5.0000 90.1258
1.0000 881.0000 6.0000 96.3174
1.0000 882.0000 7.0000 105.9038
1.0000 883.0000 8.0000 105.9038
2.0000 864.0000 1.0000 0
2.0000 871.0000 2.0000 0
2.0000 872.0000 3.0000 0
2.0000 873.0000 4.0000 0
2.0000 874.0000 5.0000 0
2.0000 881.0000 6.0000 0
2.0000 882.0000 7.0000 0
With my panels (housholds) in the first colum, (forget about the date), my t in the third panel and last tobacco expenditure in the fourth. I would like to create a frequency table that showed the frequency of the households who bought 0 tobacco (0 in all the 8 years), the housholds who bought tobacco once (one tob.exp>0) and so forth...
So the result should be something like this:
# purchases freq. %
0 1957 32.08
1 348 5.70
2 199 3.26
3 191 3.13
4 199 3.26
5 229 3.75
6 311 5.10
7 519 8.51
8 2147 35.20
Total 6100 100.0

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!