DATA Step, Macro, Functions and more

macro to generate a list of label statement, error message

Accepted Solution Solved
Reply
Super Contributor
Posts: 336
Accepted Solution

macro to generate a list of label statement, error message

%macro label(N); 
  %do I = 1 %to &N;
   label condid&I = "condition ID&I";
  %end;
%mend label;

%label(25);

i got an error message:

NOTE: Line generated by the invoked macro "LABEL".

49 label condid&I = "condition ID&I";

-----

180

ERROR 180-322: Statement is not valid or it is used out of proper order.

would you please let me know why is that? Thank you.


Accepted Solutions
Solution
‎05-04-2017 11:55 AM
PROC Star
Posts: 288

Re: macro to generate a list of label statement, error message

 

There's nothing wrong with the macro, but if you invoke it outside of a data step it's just generating invalid syntax.

 

Just use it in a data step:

 

data want;

set something;

%label(x)

run;

View solution in original post


All Replies
Solution
‎05-04-2017 11:55 AM
PROC Star
Posts: 288

Re: macro to generate a list of label statement, error message

 

There's nothing wrong with the macro, but if you invoke it outside of a data step it's just generating invalid syntax.

 

Just use it in a data step:

 

data want;

set something;

%label(x)

run;

Super User
Posts: 17,819

Re: macro to generate a list of label statement, error message

Or use PROC DATASETS to avoid recreating the dataset. 

Super Contributor
Posts: 336

Re: macro to generate a list of label statement, error message

Thank you.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 112 views
  • 2 likes
  • 3 in conversation