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 is proc sort?
Give some examples where proc report’s defaults are different than proc print’s defaults?
What will calendar procedure do?
I have 3 years of work experience at a startup and recently got certified in Data Science with SAS. I need to know how to get into the analytics industry
how to change the execute of macro
To what type of programms have you used scratch macros?
for what purpose would you use the retain statement? : Sas programming
What are the functions used for character handling?
what is hierarchy flattening? : Sas-di
for report generation which one you used proc report or data_null_?
i have a dataset with 100 obs i want to generate title from 20th obs onwards with total observations. that should contain 100 obs.dont use firstobs and dnt split the data. use dataset block or proc report? how can we genarate;
What does PROC print, and PROC contents do?
What are the features of base sas system?
What is factor analysis?
which features do you use to check the data validations and errors? : Sas-administrator