BookmarkSubscribeRSS Feed
jcis7
Pyrite | Level 9

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!


4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Astounding
PROC Star

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?

jcis7
Pyrite | Level 9

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

Haikuo
Onyx | Level 15

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1063 views
  • 0 likes
  • 4 in conversation