Below is the table.









Required to be output should be the highest number of each student_id.
Example.
Student_id Subject Marks
1 Hindi 86
2 Hindi 70
3 English 80
.

Calculate sum and average marks for each group of student_id
Example.
Student_id Subject Marks Total Marks Average
1 English 40 181 60.33333
2 English 67 196 65.33333
3 English 80 160 53.33333

PLEASE PROVIDE THE CODE OF ABOVE PROBLEMS

Answer Posted / chaudhary_1989

data a;
input id sub$ marks;
cards;
1 Hindi 86
2 Hindi 70
3 Hindi 80
1 English 80
2 English 34
3 English 39
1 Maths 28
2 Maths 45
3 Maths 12
;
run;

proc sort data = a out=b;
by id descending marks;
run;

data c (drop=total_marks) d;
set b;
by id descending marks;
if first.id then output c;
if first.id then total_marks=marks;
else total_marks+marks;
if last.id then output d;
run;

proc print; run;

proc means data = a mean max sum;
class id;
var marks;
output out=df;
run;

proc means data = a noprint nway;
class id;
var marks;
output out=df sum= mean= max= /autoname;
run;

proc print; run;

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What commands are used in the case of including or excluding any specific variables in the data set?

600


What areas of SAS are you most interested in?

1074


Explain how merging helps to combine data sets.

620


Mention what is PROC in SAS?

610


what is sas metadata repository? : Sas-bi

613






How to import multiple xls files into sas. Out of those files, how to get different values from a single variable and how to find number of rows per value type? We can do this using group by for one xls file with proc sql. Was wondering how I can achieve this for multiple files at the same time. Any ideas?

2395


How can sas program be validated?

585


If you could design your ideal job, what would it look like?

2386


what is the difference between nodup and nodupkey options? : Sas programming

629


how sas deals with business intelligence? : Sas-bi

591


Intern stastical programmer written test

292


What is the role of sas grid administrator? : sas-grid-administration

841


what are the considerations when picking a SAS/STAT procedure?

2910


Briefly explain input and put function?

641


What are the new features included in the new version of SAS Programming Language?

743