I have the following code:
%macro One (Data=, City=);
data &data;
set Dataset1;
Var_new=.;
if State = "CA" and CITYCODE = &City then output;
run;
%mend One;
%One (Data=Bakersfield_CA, City=12540);
%One (Data=Chico_CA City=17020);
I get the first dataset for Bakersfield_CA..but I get error for the second time the macro runs and I don't get any dataset called "CHico_CA".
You're missing a comma in your second macro call. Try
In general, though, creating lots of little datasets like this is a bad idea, as it makes your code much more complicated than necessary. What are you trying to do for each city? You can probably do the same thing with your original
dataset1
using by-group processing.