DATA Step, Macro, Functions and more

Macro not working

Reply
Regular Contributor
Posts: 194

Macro not working

Hi, I'm new to macros and cannot figure out why this doesn't work:

I have a bunch of questions I'm running the chi-square test on comparing two groups so I'm trying to create a macro.

The question names are:

q1_volun

q1_sec

etc....


I ran the code without the macro and it worked fine using the question names.

center pagesize=45 nonumber nodate symbolgen;


%macro analysis(question);

proc freq data=q1;

tables group*&question./chisq;

title "&question. - Chi-Sq - verifies info";

run;

%mend analysis;
%analysis (q1_vol);

%analysis (q1_sec);

Any help you can give is much appreciated!  Thanks!


Super User
Super User
Posts: 7,942

Re: Macro not working

Hi,

You would need to be more specific, what doesn't work, what errors/warnings in the log, maybe also what data are you using, provide a datastep with some test data.  The code seems fine.

Super User
Posts: 5,497

Re: Macro not working

The macro looks fine, especially if the same code ran without using a macro.  One thing is suspect, though.  You have a line:

center ... symbolgen;

These are options, so the word OPTIONS should be there:

options center ... symbolgen;

Could that be the problem?

Regular Contributor
Posts: 194

Re: Macro not working

Posted in reply to Astounding

Thank you everyone! I closed out SAS and opened it and it miraculously worked. 

Respected Advisor
Posts: 3,156

Re: Macro not working

If you don't want to restart your SAS, here is some magic strings sometimes may work for you:

*))%*))*/;

;;;;

%mend;

options notes;

run cancel; quit;

proc unk; run;

 

Haikuo

Ask a Question
Discussion stats
  • 4 replies
  • 267 views
  • 0 likes
  • 4 in conversation