Can you calculate the mean, median and mode of the following data set
using data step logic? Don't use any function or procedure.
data a;
input age @@;
datalines;
22 32 32 32 43 23 24 56 45 54 28 29 27 26 25 28 30 20 18 37 36 47 46
56 19 20
;
run;
I have calculated the mean which i have posted in the answer section.

Answer Posted / chandrakanth

options firstobs=1 obs=26;
data a;
input age @@;
datalines;
22 32 32 32 43 23 24 56 45 54 28 29 27 26
25 28 30 20 18 37 36 47 46
56 19 20
;
run;

proc sort data=a out=ab;
by age;
run;

options firstobs=13 obs=14;
data c;
set ab end=last;
sum_age+age;
if last then median=sum_age/2;
run;

we need observation 13 and 14 because total number of observations is n=26 when n is even we need to do mean of two observations n/2 and (n/2)+1 which is 13th and 14 th observations in this case.
let me know if you need more help... I'm still thinking about mode...will send once I get it

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What can be the size of largest dataset in SAS?

717


what is treatment emergent events and treatment emregent adverse event

1941


I am preparing SAS Certified Advanced Programmer for SAS 9 in 2014. If anybody has the latest dumps for this exam, please mail me at dhiman.mukherjee@gmail.com

2261


what is SAS OPTIMIZATION?

1817


How will you react when, while consulting a SAS documentation manual to get an answer to a problem, someone says hey, I thought you were supposed to know all that stuff already, and not have to look it up in a book?

1944






how would you create multiple observations from a single observation? : Sas programming

566


In proc transpose and data step with arrays which one you pick?

2574


what is sas application server? : Sas-di

541


What function CATX syntax does?

689


Name types of category in which SAS Informats are placed?

736


how to do user inputs and command line arguments in sas?

2428


What system options would you use to help debug a macro? : sas-macro

636


how are numeric and character missing values represented internally? : Sas programming

619


What does PROC print, and PROC contents do?

730


Explain how you can debug and test your SAS program?

565