If I have a variable (var) such that if category= A then the value of var is 1, if category=B then value of var is 2, and if category =C then the value of var is 3 and I want to create indicator variables for these three categories of var, called var_1, var_2, and var_3 using macros, would it be correct to say
%macros Create_indictor (num=);
data= mydata;
if var= &num then %put var_#
run;
%mend Create_indicator;
%Create_indicator (num=1);
%Create_indicator (num=2);
%Create_indicator (num=3);
Let's not reinvent the wheel 🙂
SAS provides functionality to handle categorical variables, depending on your procedure.
Or you can use the methods here:
http://blogs.sas.com/content/iml/2016/02/22/create-dummy-variables-in-sas.html
At the bottom of this page there are three other links with ways to create dummy variables
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.