From the course: SAS Programming for R Users, Part 2

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Creating global macro variables: Automating the process

Creating global macro variables: Automating the process - SAS Tutorial

From the course: SAS Programming for R Users, Part 2

Creating global macro variables: Automating the process

- [Narrator] So we just saw how to create macro-variables manually with the %less statement, and now let's automate the process using SQL. Well, step one, in order to query a data set, we need to actually have data set with useful information, so in this case I'm running the means procedure using the output statement to create a new SAS data set with the values for mean and standard deviation. So the variable names in this data set stats are going to be mean and SD. Now I can go ahead and query that data and create new macro-variables. To do so, I'll use PROC SQL and I'll start with the select statement, and specify the variable name in my data set, in this case, mean. I'll use the keyword 'into' and the colon operator and specify a new macro-variable that I'm creating, sp_mean. And finally I need to tell it what data set I'm looking into from stats. And likewise, I'm going to select the standard deviation and put that into a new macro-variable called sp_sd, again from the stats data…

Contents