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
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!
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.