BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Thalitacosta
Obsidian | Level 7

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
PaigeMiller
Diamond | Level 26

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

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 388 views
  • 1 like
  • 2 in conversation