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
what r the job openings SAS for fresher graduates !
How to limit decimal places for the variable using proc means?
what is data governance? : Sas-di
Name and describe few sas character functions that are used for data cleaning in brief.
Explain substr function?
name the scheduler for scheduling job and explain the scheduler? : Sas-di
what is factor analysis? : Sas-administrator
what is sas and what are the functions? : Sas-administrator
Are you involved in writing the inferential analysis plan? Tables specfications?
explain the use of % includes a statement in sas? : Sas-administrator
What versions of SAS have you used (on which platforms)?
how to debug and test the sas program? : Sas-administrator
State the difference between INFORMAT and FORMAT ?
How to create a permanent sas data set?
How would you identify a macro variable?