## Solution needed with both datastep and report procedure

Solved
Occasional Contributor
Posts: 19

# Solution needed with both datastep and report procedure

Input:

21

22

21

21

23

22

21

21

22

23

22

Needed ouput:

distinct   times

21           5

22           4

23           2

Accepted Solutions
Solution
‎01-22-2017 04:19 PM
Super User
Posts: 6,648

## Re: Solution needed with both datastep and report procedure

Getting the total should be just for reporting purposes and not part of the data itself.  One way:

proc freq data=have;

tables distinct / noprint out=counts (keep=distinct count rename=(count=times));

run;

proc print data=counts;

var distinct times;

sum times;

run;

All Replies
Occasional Contributor
Posts: 19

## Re: Solution needed with both datastep and report procedure

Sorry, I need the total for time too.
Needed ouput:

distinct times

21 5

22 4

23 2
Total 11
Posts: 1,831

## Re: Solution needed with both datastep and report procedure

data test;

input var;

datalines;

21

22

21

21

23

22

21

21

22

23

22

;run;

1) proc freq data=test; table var; run;

2) proc means data=test;

class;

var var;

output out=test1 N=;

run;

I haven't run it so check it carefully.

Solution
‎01-22-2017 04:19 PM
Super User
Posts: 6,648

## Re: Solution needed with both datastep and report procedure

Getting the total should be just for reporting purposes and not part of the data itself.  One way:

proc freq data=have;

tables distinct / noprint out=counts (keep=distinct count rename=(count=times));

run;

proc print data=counts;

var distinct times;

sum times;

run;

☑ This topic is solved.