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;
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;
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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.