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 is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 641 views
  • 2 likes
  • 3 in conversation