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
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: