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

explain what is data set in sas? : Sas-administrator

522


What does the RUN statement do?

845


What do you know about symput and symget?

721


How would you identify a macro variable? : sas-macro

526


Differentiate between proc means and proc summary.

599






what has been your most common programming mistake? : Sas programming

557


What is a method for assigning first.VAR and last.VAR to the BY group variable on unsorted data?

1998


Describe 5 ways to do a “table lookup” in SAS?

695


How is character variable converted into numeric variable and vice versa?

587


What are the uses of sas?

695


how to create the AE dataset by using SDTMIG specifications and SAP plan by using UNIX platform?

2284


Name and describe few sas character functions that are used for data cleaning in brief.

658


Explain translate function?

624


How would you invoke a macro? : sas-macro

543


Differentiate input and infile.

592