BookmarkSubscribeRSS Feed
juliajulia
Obsidian | Level 7

 

can somebody help me take a look at the following macro code to see what's wrong with it. i can run the proc tabulate without macro and no error but when i put it to the macro, it give me the syntax error message:


without macro (no error):

proc tabulate data=adr.clientinfo2019 format=8.1;
class age race ;
table age='' all={label="Subtotal"}, race*(n="No." colpctn="col Percent" ) all={label="Total"} / printmiss box="";
format age age2fmt.;
run;

/***has error when i run the following code**/

%macro colT(dset,colvar,var);
proc tabulate data=&dset. format=20.4;
class &colvar &var ;
table &var.="" all={label="Subtotal"}, &colvar*(n="No." colpctn="Col Percent") ;
run;
%mend colT;
%colT (data, racee age) ;

error message:

NOTE: Line generated by the invoked macro "COLT".
1 proc tabulate data=&dset. format=20.4; class &colvar &var ; table &var.=""
-----
180
1 ! all={label="Subtotal"}, &colvar*(n="No." colpctn="Col Percent") ; run;
ERROR 180-322: Statement is not valid or it is used out of proper order.

 

 

3 REPLIES 3
Quentin
Super User

Look like you might be missing a comma in the macro call.  Did you mean:

%colT (data, racee, age)
The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
juliajulia
Obsidian | Level 7

oh, i missed a comma between the %colT (data, raceeth, age) . Thank you so much.

ballardw
Super User

You can see more details of problems by setting Options mprint (and sometimes mlogic and symbolgen) before running the macro with problems.

 

options mprint;

%colT (data, racee age) ;

options nomprint;

In this case if that is the code you submitted then @Quentin is correct. You did not pass a value for the VAR parameter and so you would get a table statement that looks like:

table  ="" <other stuff>

When pasting text copied from the log you should open a text box on the forum using the </> icon that appears above the message window and paste the copied text there. The message windows reformat text so the diagnostic characters like the underscores do not appear where they actually did in the log window.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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