Create a Macros in SAS.

Using the MyOpenMath generated data, replicate the work done in my examples.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Create a macro in SAS with three variables: one for the data set you are inputting, one for the metric that you want to find, and one for the variable that you are calculating said metric on. This one macro should work for both of the questions.

For the hockey data, find the median of goals allowed.

For the house data, find the standard deviation of square footage.

Provide screenshots and code that show your macro with the three variables and how you ran the code to find the answers (that you should also submit to MyOpenMath).

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

provides answers and screen shot of codes in SAS in word file. Please. Thanks. Example of the HW is also provided below.

5
Macros (and Functions)
• A macro in SAS (and similarly, a function in R) is the way we can repeat a similar process with small
changes. It can be very helpful to avoid duplicating code, especially when that code later needs adjustments.
(An example of this in my current life: I have some relatively complex code that pulls in data for each
baseball team and does stuff with that information. Rather than copy and paste that same code 29 times
(once for each team), I built a function where I pass the team name through, and then the code finds the
same information for each team.)
Examples
• Example
– The following screenshot shows the average of the variable “home runs” in the baseball data set as
13.8.
• SAS Code
– You’ll notice that my macro only has one variable; you’re asked to create one with three. A few notes
follow below.
– First, separate different variables with a comma.
– Second, leaving nothing after the equal sign says that there’s no default; it’s common for that to be
left blank, but it wouldn’t be crazy to create a macro where the metric defaults to something like
mean or median. (When you run the macro (the last line) if you type something after the equal sign
it overrides the default, and if you leave it blank, it runs the default. Obviously if you have no default
and nothing typed after the equal sign SAS will be confused!)
– Third, as seen in the third line, the ampersand (&) is what calls the different inputs into the macro.
1
• R Code
– Similarly to SAS, you can set a default in R. However, there is no equal sign in the first line of the R
code, so any default simply needs to add that.
– As seen, there is nothing special to call the code inputs in R.
2

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER