tags:

views:

136

answers:

1

Hi,

I'm trying to calculate the frequency of fractions in my data set (excluding whole numbers).

For example, my variable P takes values 24+1/2, 97+3/8, 12+1/4, 57+1/2, etc. and I'm looking to find the frequency of 1/2, 3/8, and so on. Can anyone help?!

Thanks in advance!

Clyde013

+2  A: 

hi, Clyde013, here is one way, assuming that p is of character type. hth. cheers, chang

> Pulled from SAS-L

/* test data -- if p is a character var */ 
data one; 
input p $ @@; 
cards; 
24+1/2 
97+3/8 
12+1/4 
57+1/2 
36 3/8 ; 
run;

/* frequencies of frations? */ 
data two; 
set one; 
whole = scan(p, 1, "+"); 
frac = scan(p, 2, "+"); 
run; 

proc freq data=two; 
tables frac; 
run; 

/* on lst 
                       Cumulative Cumulative 
frac Frequency Percent Frequency  Percent
--------------------------------------------------------- 
1/2          2  50.00          2    50.00 
1/4          1  25.00          3    75.00 
3/8          1  25.00          4   100.00

Frequency Missing = 2 */
Jay Stevens