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



Below is the table. Required to be output should be the highest number of each st..

Answer / 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

More SAS Interview Questions

What does the trace option do?

0 Answers  


what is the difference between proc means and proc tabulate?

3 Answers   Cognizant, CTS,


Difference between informat and format?

0 Answers  


What is difference between rename and lable in sas?

10 Answers   Satyam,


what is syntax of proc merge ?

7 Answers   TCS,






How to test the debugging in sas?

0 Answers  


how to get second highest salary from a employee table and how get a 5th highest salary from a employee table?

11 Answers   ABC, Amex,


Describe how you would pass data to macro.

3 Answers  


What are exact SAS Base contents..?N what r SAS Tools..?

1 Answers  


Given an unsorted data set, how to read the last observation to a new data set?

0 Answers  


How would you remove a format that has been permanently associated with a variables?

3 Answers  


you have a data set like this. data qqq; input name $ total; cards; qq 22 ww 33 qq 22 ee 44 rr 33 ww 44 ; run; and you want output like this......... name total qq 22 ww 44 Do it by data set step.

6 Answers  


Categories