0
votes

I am writing a macro for a school assignment that will pass the name of an airline to the macro, I am sure it has something to do with character strings and " and ' that are missing, But it will not run. Please tell me what I am doing wrong.

%macro select airine=;

proc means data=mytables.airtraffic noprint ;
where bosflights gt 0 and bospassengers gt 0;
by &airline;
var bosflights bospassengers;
output out=mytables.bosflightsairport sum (bosflights bospassengers)=  flights passengers;`
run;
%mend select;
%select airline = Envoy Air;
1
I had fixed that but still got ERROR 22-322: Syntax error, expecting one of the following: a name, ;, DESCENDING, NOTSORTED, ALL, CHARACTER, CHAR, NUMERIC.kahunabee

1 Answers

2
votes

You are missing the () in your macro definition and call.

%macro select(airline=);
...
%mend select;
%select(airline = Envoy Air);

Are you passing in the name of the variable or the value of the variable? The way you have written now you are passing in two variable names ENVOY and AIR that you want to use to group the data in the AIRTRAFFIC dataset.

If you meant the parameter value to be used to subset the data then assuming you have a variable named AIRLINE in the dataset then you probably want something like this as the body of your macro.

proc means data=mytables.airtraffic noprint ;
  where bosflights gt 0 and bospassengers gt 0;
  where also airline="&airline";
  var bosflights bospassengers;
  output out=mytables.bosflightsairport
         sum(bosflights bospassengers)=  flights passengers
  ;`
run;