Thanks so much, ballardw! Your suggestion successfully answered my first question. For my second question, I had to run proc means by type & specialty to get the mean of visits per year for each specialty. This is how I used your code: Proc summary data=freqVisits; class Specialty Year_of_Visit; output out=work.counts; proc print; run; _type_ = 2 gives results similar to proc freq; tables Specialty; _type_ = 3 stratifies the frequency of visits to each specialty by year. The following to show how the proc summary statement worked: Specialty Year_of_Visit _TYPE_ _FREQ_ Specialist 2 . 2 77 Specialist 7 . 2 1 Specialist 3 . 2 17 Specialist 2 2003 3 1 Specialist 2 2004 3 1 Specialist 2 2007 3 5 Specialist 2 2008 3 3 Specialist 2 2009 3 5 Specialist 2 2010 3 11 Specialist 2 2011 3 11 Specialist 2 2012 3 10 Specialist 2 2013 3 16 Specialist 2 2016 3 11 Specialist 2 2017 3 3 Specialist 7 2010 3 1 Specialist 3 2010 3 2 Specialist 3 2011 3 1 Specialist 3 2013 3 1 Specialist 3 2014 3 2 Specialist 3 2015 3 11 /* To calculate (mean ± SD) of visits per year */ proc means data = counts; var _freq_ ; where _type_ = 3; run; The result was the following: Analysis Variable: _FREQ_ N Mean Std Dev Minimum Maximum 17 5.5882352 4.9378490 1.0000000 16.0000000 /* To calculate (mean ± SD) of visits per year by specialty type*/ proc means data = counts; var _freq_ ; by Specialty ; where _type_ = 3; run; The results were the following: Specialty=Specialist 2 Analysis Variable: _FREQ_ N Mean Std Dev Minimum Maximum 11 7.0000000 5.0000000 1.0000000 16.0000000 Specialty = Specialist 7 Analysis Variable: _FREQ_ N Mean Std Dev Minimum Maximum 1 1.0000000 . 1.0000000 1.0000000 Specialty = Specialist 3 Analysis Variable: _FREQ_ N Mean Std Dev Minimum Maximum 5 3.4000000 4.2778499 1.0000000 11.0000000 Thanks so much again!
... View more