简体   繁体   中英

Passing Parameters in a SAS Macro

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;

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM