Question: I am trying to write a SAS program where I import excel files and create a merge b/w them after finding the average. However, the

I am trying to write a SAS program where I import excel files and create a merge b/w them after finding the average.

However, the code is not averaging all players.

PROC IMPORT DBMS=xlsx OUT=more_rate replace

DATAFILE="/folders/myfolders/sasuser.v94/Baseball_More_Rate.xlsx";

GETNAMES=YES;

RUN;

data rate;

set work.more_rate;

run;

*Find the average OBP for each of the "rate" baseball data;

proc means data = rate noprint;

output out = avg_obp1 mean(OBP) = a_average;

run;

data avg_obp;

merge rate avg_obp1 (drop=_TYPE_ _FREQ_); *Append the data to baseball_more_rate.xlsx;

run;

proc print data = avg_obp;

*******************************************;

PROC IMPORT DBMS=xlsx OUT=more_rate2 replace

DATAFILE="/folders/myfolders/sasuser.v94/Baseball_Min_Rate.xlsx";

GETNAMES=YES;

RUN;

data rate_for_min;

set work.more_rate2;

run;

*Find the average OBP for each of the "rate" baseball data;

proc means noprint data = rate_for_min;

output out = avg_obp2 mean(OBP) = league_avg_obp;

format league_avg_obp 6.4;

run;

data league_avg_obp;

merge rate_for_min avg_obp2 (drop=_TYPE_ _FREQ_); *Append the data to Baseball_Min_Rate.xlsx;

merge rate avg_obp1 (drop=_TYPE_ _FREQ_);

run;

proc print data = league_avg_obp;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!