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

data b;
set a end=lastobs;
age_temp+age;
count+1;
if lastobs then
mean=age_temp/count;
if _n_=13 then
Median=Age; /*median is the mid value */
run;
proc sort data=b out=c;
by age;
run;
data d;
set c;
if first.age=0 and last.age=0 then
Mode=age;/*mode is the most repeated value*/
by age;
run;

Is This Answer Correct ?    3 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what r the job openings SAS for fresher graduates !

2015


How to limit decimal places for the variable using proc means?

601


what is data governance? : Sas-di

625


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

668


Explain substr function?

577






name the scheduler for scheduling job and explain the scheduler? : Sas-di

592


what is factor analysis? : Sas-administrator

613


what is sas and what are the functions? : Sas-administrator

542


Are you involved in writing the inferential analysis plan? Tables specfications?

1746


explain the use of % includes a statement in sas? : Sas-administrator

548


What versions of SAS have you used (on which platforms)?

1015


how to debug and test the sas program? : Sas-administrator

572


State the difference between INFORMAT and FORMAT ?

599


How to create a permanent sas data set?

678


How would you identify a macro variable?

651