 Hi there, it's me, Monica Wahee, ushering you toward a deeper understanding of SAS On Demand for Academics, otherwise known as SAS ODA. In this video, I'm going to show you how to store a SAS macro in one file and call it up in another file. Okay, here we are in the SAS On Demand for Academics or SAS ODA environment. If you need help setting up your free account in SAS ODA, you can take my free online course that will help you, which is called Getting Started with SAS ODA. Name is short, sweet, and to the point. I'll link you to it in the description. Okay, assuming you got started with SAS ODA, you now know how to open a program window and put some code in it. So please, if you want to follow along, go get this code from GitHub and paste it into the program window. Okay, if you've watched my previous videos, this code looks familiar. This is just the macro code we set up to create the macro. How do you know? You can see it starts with the macro command and ends with the mend command. Remember, this macro made a flag, so we called it make underscore flag. We are using the BRFS data set, which is data from an annual phone health survey done in the United States. So they asked the respondents if they had all kinds of different diseases, like asthma, heart attack, and heart disease. And I didn't like the coding of these native variables. They had one equals yes and two equals no and a bunch of other values I didn't care about. So the purpose of this macro is to create binary flag variables for each of these conditions so that the flag says one if the respondents said yes and says zero if they said anything else. As I showed you in the last video, by putting all of these arguments in the macro command when we make the macro, we are insisting that SAS ask for parameter inputs for each of these macro variables before we run the macro. So when we run the macro, we will say make underscore flag, and then we will have to define values for each of these macro variables in parentheses. Okay, so this is our macro code, and we can just store this code in a file. In fact, let's save it. Let's call it make underscore flag. I'll click on the save button. Okay, the highest level on the tree you can save this is where it says files home. So let's click on that, then let's name it make underscore flag and click save. Okay, see it? It is saved there. All right, now let's look at the code I put in program two over here. Okay, this is the code we are going to use to call that macro I just saved called make underscore flag. Before, I showed us running the macro in the same code where we made it. But when you run a data warehouse, you don't want to embed your macro code in with the code where you call the macros. Otherwise, you will never be able to find your macros. And you want to make sure you can launch the same macro from any ETL code. So you have to know where they all are. So this code in front of us just launches macros. It starts with an include statement. See this statement? It is just telling SAS where the code file is that has the macro in it. And actually, we have to edit this path because we need to point it to our new macro file we just saved. Here, let's right click on the new macro file and choose properties to see what the path is. See where it says location? We are going to copy that and put that in as our path. Let me do that now. I'll just edit the code. Okay, there. Now, SAS should be able to find the macro file. So how do we launch this macro from the separate code file? Well, first, we have to actually run the include command. So let's highlight include and run and run this. Okay, well, that looks like it ran. Let's go back to the code. So now, let's actually launch the code. Now, you will see that I'm picking up from where we left off from the video on adding conditions to macros. So the disease I'm on is skin cancer. In the previous videos, we did asthma, heart attack, heart disease. I forgot the others. But now we are up to skin cancer. So let's look at how we launch the macro. So here, we use the percent sign and the name of the macro, make underscore flag, to call the macro. But notice how we can't forget to fill in the values of all the macro variables so that the macro will make our flag. Remember, it's taking in native variable CHC SCNCR, which has the coding of one for yes and two for no and a bunch of other values I don't care about. And it is transforming it into our flag variable called skinCA underscore flag. That's what the macro will do. And also, you see that the data set we are reading in is BRFSS underscore D and the output data set is specified as BRFSS underscore E. So this should work if I highlight this line of code and run it. Let's see if it does. Well, viewing these results, it looked like the macro ran. So now you know how to store macros and files separately from where you call them. So when you are working in my data warehouse someday, I hope I never find a bunch of messy code with embedded macros in it. I would expect to find some neat macro files all lined up in a nice clean storage area and to see you calling them neatly in ETL code, just a hint for those of you looking for jobs in a data warehouse. Want to learn more about SAS so you can come off as really competent in a job interview for a SAS position? You will sound like a pro after taking my free online course in How to Use SAS on Demand for Academics. All these lessons are based on my exclusive but frank book, Mastering SAS Programming for Data Warehousing. I'll link to these in the description. Thanks for watching and have an energetic day.