%macro carmake(Make= , Models=);
data cars;
set sashelp.cars;
where Make in (&make)and Model in (&models);
run;
%mend;
%carmake(Make= "Acura" "Audi" "BMW" "Hyundai", Models= "SUV" "Sedan");
Last time I looked at the SASHELP.CARS data set the variable TYPE had values like "SUV" and "Sedan".
Model has stuff like "RSX Type S 2dr".
So expect 0 observations in the result using Model that way.
Not executing? Why do you say so?
If I submit, I get a dataset with zero observations in return!
So, it works !
Koen
Last time I looked at the SASHELP.CARS data set the variable TYPE had values like "SUV" and "Sedan".
Model has stuff like "RSX Type S 2dr".
So expect 0 observations in the result using Model that way.
Thaks for help my bad I have fixed the issue
%macro carmake(Make= , Types=);
data cars;
set sashelp.cars;
where Make in (&make)and Type in (&Types);
run;
%mend;
%carmake(Make= "Acura" "Audi" "BMW" "Hyundai", Types= "SUV" "Sedan");
Part of the problem is that you did not follow the general recommended advice, to first create code that works properly without macro variables and without macros. Had you done that, perhaps you would have figured out the problem, and then your macro would work properly.
But without macro variables and without macros, your code is this
data cars;
set sashelp.cars;
where Make in ( "Acura" "Audi" "BMW" "Hyundai") and Model in ("SUV" "Sedan");
run;
which doesn't work the way you want either. It returns an empty data set.
So please follow the above very good advice. You need to first make this code work without macros and without macro variables, and then you should be able to make your macro work properly.
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!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.