Question: Program to be wrapped in a macro for Problem B. When the following 5A5 program data numweeksbest; set sta402.weeks_best; by best notsorted; if first.best then

Program to be wrapped in a macro for Problem B. When the following 5A5 program data numweeksbest; set sta402.weeks_best; by best notsorted; if first.best then streak=0; streak + 1; if 1ast.best than output; run; is applied to the weeks_best.sas?bdat data set it identifies the length of each streak {number of consecutive equal values) for the values given in the variable best. See the example below. Example illustrating the original program given in Problem B. The data set weeks_best.sas7bdat contains one variable, best, giving the top-ranked organization for each week of a season. Applying the program above to this data set creates a new data set of twelve observations with variables named best and streak. The first three observations in the new data set indicate that Foxville Frogs was the leader for the first 4 weeks, then Muncie Mudflaps led for 1 week, then Hamburg Hares led for 2 weeks, and then Foxville Frogs again for 2 weeks, etc. The first few observations for the original and created data sets are shown below. Original Data Set Obs best Foxvllle Frogs Foxville Frogs Foxvllle Frogs Foxvllle Frogs Muncie Mudflaps} Streak of length 1 Hamburg Hares Hamburg Hares } Streak of length 2 Foxvllle Frogs Envnillh EI'I'LI'II' Streak of length 4 o m u m m e w M H 1* Streak of length 2 Created Date Set Obs best streak 1 Faxville Frogs 4 2 Muncie Mudflaps l 3 Hamburg Hares 2 4 Foxville Frogs 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
