Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

data temp;
input age @@;
cards;
8 7 7 2 67 9 7 7 1 2 45 34 22 45 23 8 34 23
run;


proc sort data=temp; by age ;run;

data a(keep = median mode_age mean);
last_age=age;
retain max_cnt mode_age median;
set temp end=lastobs nobs=n;
by age;
age_temp + age;

/*Median */
if mod(n,2) = 1 and _n_ = (n+1)/2 then do ;median=age; end;
if mod(n,2) = 0 and _n_ = (n+2)/2 then do ;median=(age + last_age)/2; end;

/*Mean*/
if lastobs then do mean=age_temp/n ; end;

/*Mode */
if first.age then cnt =1; else cnt+1;
if last.age then lst_cnt=cnt;
if lst_cnt > max_cnt then do; max_cnt = lst_cnt; mode_age = age;end;


if lastobs then output;
run;

Is This Answer Correct ?    9 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how will you location sas platform applications available from web browser? : Sas-bi

1043


How would you code a macro statement to produce information on the sas log? This statement can be coded anywhere? : sas-macro

1009


What is the difference between %local and %global? : sas-macro

1141


How do you specify the number of iterations and specific condition within a single do loop?

1067


Tell e how how dealt with..

2189


If you were told to create many records from one record, show how you would do this using array and with proc transpose?

1442


why a stop statement is needed for the point= option on a set statement?

1035


Explain by-group processing?

963


how do you pull data from equifax?tell me the process?

1760


sas implementing companies in pune implementing clinical projects if anyone knows plz send ans immediately

3551


For what purposes have you used sas macros? : sas-macro

967


describe the interaction table in sas di? : Sas-di

991


Give an example where SAS fails to convert character value to numeric value automatically?

1044


WHAT IS SAS WEB SERVICE and what are the steps to create an xml service ?

2763


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

970