Construct frequency tables