code to get frequencies & do cluster analysis