Editor's Note: This solution, along with the addition of the following in a later post:
Change the statement to avg(ques1+quest2) as avg to avg(ques+quest2)/2 as avg in select statement in 2 and 3...
provide answers to all questions asked. Thanks also to @SteveDenham for providing a PROC MEANS alternative.
You can also use Proc Sql with Group by and Having clauses, if you are good with Proc Sql;
Below is the code for the your questions 2,3 4 in the order:
proc sql;
create table b as
select fruit, ques1, quest2, avg(ques1+quest2) as avg
from a;
quit;
proc sql;
create table c as
select fruit, ques1 , quest2, avg(ques1+quest2) as avg1
from a
group by fruit
having fruit in ('Banana', 'Apple');
quit;
proc sql;
create table d as
select fruit, ques1 , quest2, avg(ques1) as avg2
from a
group by fruit
having fruit in ('Banana');
quit;
~ Sukanya E
Editor's Note: This solution, along with the addition of the following in a later post:
Change the statement to avg(ques1+quest2) as avg to avg(ques+quest2)/2 as avg in select statement in 2 and 3...
provide answers to all questions asked. Thanks also to @SteveDenham for providing a PROC MEANS alternative.
You can also use Proc Sql with Group by and Having clauses, if you are good with Proc Sql;
Below is the code for the your questions 2,3 4 in the order:
proc sql;
create table b as
select fruit, ques1, quest2, avg(ques1+quest2) as avg
from a;
quit;
proc sql;
create table c as
select fruit, ques1 , quest2, avg(ques1+quest2) as avg1
from a
group by fruit
having fruit in ('Banana', 'Apple');
quit;
proc sql;
create table d as
select fruit, ques1 , quest2, avg(ques1) as avg2
from a
group by fruit
having fruit in ('Banana');
quit;
~ Sukanya E
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.