Obsidian | Level 7

## SUM OUTPUT DATA

I have a data output in sas with the following information:

rating dt iep

A 202201 10

B 202201 12

C 202201 15

A 202203 13

B 202203 14

C 202203 17

How to create a new table with the sum by "dt" of the column "iep"? So it's like this:

rating dt iep CRITERION

A 202201 10

B 202201 8

C 202201 5

23 DIFFERENT

A 202203 13

B 202203 14

C 202203 17

44 SIMILAR

In which "rating" is categorical, "dt" is numeric, "iep" is numeric, and "criterion" is created from the condition:

if sum(iep) < 25 then criterion = different;

else criterion = similar;

1 ACCEPTED SOLUTION

Accepted Solutions
Diamond | Level 26

## Re: SUM OUTPUT DATA

UNTESTED CODE

``````proc summary data=have;
class dt;
var iep
output out=sums sum=;
run;
data want;
set have sums(in=in2);
by dt;
length criterion \$ 9;
if in2 and iep<25 then criterion='DIFFERENT';
else if in2 and iep>=25 then criterion='SIMILAR';
run;``````
--
Paige Miller
Diamond | Level 26

## Re: SUM OUTPUT DATA

UNTESTED CODE

``````proc summary data=have;
class dt;
var iep
output out=sums sum=;
run;
data want;
set have sums(in=in2);
by dt;
length criterion \$ 9;
if in2 and iep<25 then criterion='DIFFERENT';
else if in2 and iep>=25 then criterion='SIMILAR';
run;``````
--
Paige Miller
Discussion stats