Summary
This chapter guided us on how to create macros and macro variables to automate ETL code in SAS. We started this chapter by developing base code that ran PROC FREQ
. We further developed that base code into a macro that allowed us to set a macro variable for selected_state
so we could filter by state in our PROC FREQ
. We went on to develop a macro called %make_flags
that used data steps to automatically generate two-state flags based on variables from a survey about health conditions. When we found one of the variables, DIABETE3
, had slightly different coding, we rebuilt our macro to handle this conditional coding and called it %make_flags_conditional
. After this, we covered different alternatives for storing and calling up macros. Finally, we ended by developing a macro that read SAS files automatically.
Although there is a lot to know about macro coding, an important lesson in this chapter was to develop base code first and then build it into macro code step by step. Becoming...