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
How would you define the end of a macro?
Mention what is PROC in SAS?
what is the purpose of _error_? : Sas programming
what cause the "error: connect:" and "error in the libname statement" when there weren't any such problems?
Mention sas system options to debug sas macros.
do you prefer proc report or proc tabulate? Why? : Sas programming
what is sas application server? : Sas-di
Which function is used to count the number of intervals between two sas dates?
how does sas handle missing values in functions? : Sas programming
how can you put a "trace" in your program? : Sas programming
I need level 2 to 5 sas using companies in india
What is the difference between SAS functions and procedures?
what is data integration? : Sas-di
What do you understand by the term Normal Distribution?
explain about sas business intelligence? : Sas-bi