there must be other ways to obtain the information you need from a "function-style" macro because between the 🙂 and 😉 of a statement using your "function-style" macro like [pre] 🙂 %maxcol( some.data_set ) 😉 [/pre] your macro cannot generate any semi-colons, and certainly not a step, without interrupting the statement in which %maxcol() is used.
Without generating semi-colons, there are ways to obtain for example:
* the NOBS of a SAS data set ~ from sashelp.vtable
* the maximum value of a variable in a dataset
If the macro must use open() fetch() and other functions, they must be called within a %sysfunc() "environment", not as plain base SAS syntax like proc contents data= &syslast out= _data_ noprint; run;
A function-style macro must generate only macro language statements, because everything else is the result returned by your macro.
You will need to recognise and understand the semi-colons that are part of your macro language statements and those which are generated.
The semi-colon of a %let statement is macro language.
In the macro statement [pre] %if &A eq &B %then %do ;
A
%end ;[/pre] no semi colons are generated. However this will generate four semi-colons[pre] %if not %sysfunc( exist( &ds )) %then %do ;
data _null_ ; file print ; put "no data in &ds"; run;
%end ;[/pre]
Hope this helps clarify what a "function-style" macro needs, and why your proposal could not work.
Good Luck
PeterC
Message was edited by: Peter.C