Wendy, Here is another solution which uses some sql and a variation in the initial data step. data x; input code : $10. @@; drop i_char code; obs = _n_ ; do i_char = 1 to length(code) ; single_char = substr(code,i_char,1) ; output ; end ; datalines; I J QJ . . JQ IJ>Q . > . JIJ QJI ; proc sql ; create table x_short as select distinct obs ,single_char from x ; select max(obs) into :num_obs from x ; select single_char as code ,count(*) as count ,&num_obs as nobs ,(calculated count /&num_obs) as percent format percent5.0 from x_short group by single_char ; quit ; code count nobs percent 4 12 33% > 2 12 17% I 4 12 33% J 6 12 50% Q 4 12 33%
... View more