Calcite | Level 5

## Using Macro to find MLE

The Question:

1. Create a macro to conduct the following analysis:
• Depending on the user-specified option, compute one of the following estimators for batting average:
• Maximum Likelihood Estimator (MLE): Pi=xi/n
• Bayesian Estimator (BE):

i already cleaned the data by using data step:

DATA Q1;
input
ID
Name : \$14.
TeamandLeague : \$21.
BattingAverageFirst45 \$
BattingAverageRemainderSeason \$
AtBatsRemainderSeason ;
DATALINES;
1 Clemente (Pitts,NL) .400 .346 367
2 F.Robinson (Balt,AL) .378 .298 426
3 F.Howard (Wash,AL) .356 .276 521
4 Johnstone (Cal,AL) .333 .222 275
5 Berry (Chi,AL) .311 .273 418
6 Spencer (Cal,AL) .311 .270 466
7 Kessinger (Chi,NL) .289 .263 586
8 L.Alvarado (Bos,AL) .267 .210 138
9 Santo (Chi,NL) .244 .269 510
10 Swoboda (NY,NL) .244 .230 200
11 Unser (Wash,AL) .222 .264 277
12 Williams (Chi,AL) .222 .256 270
13 Scott (Bos,AL) .222 .303 435
14 Petrocelli (Bos,AL) .222 .264 538
15 E.Rodriguez (KC,AL) .222 .226 186
16 Campaneris (Oak,AL) .200 .285 558
17 Munson (NY,AL) .178 .316 408
18 Alvis (Mil,NL) .156 .200 70
;
RUN;
PROC PRINT data=Q1;
RUN;

I dont know the conditions im supposed to write if i use the %if %then %else method.

can anyone help me in solving this question?

2 REPLIES 2
Tourmaline | Level 20

Jade | Level 19

## Re: Using Macro to find MLE

The macro language mainly exists to generate sas code, avoiding repetitive work.

Discussion stats
• 2 replies
• 363 views
• 1 like
• 3 in conversation