BookmarkSubscribeRSS Feed
TJ87
Obsidian | Level 7

I would like to test for interactions between variable A and a set of variables (B1-B10).

In the program below, I create the interaction term (A*B) in the data step, then use the interaction term in the proc logistic step.  

Could someone please suggest a macro that would help me test all ten interactions? Thank you.

 

data new;

set have;
int=A*B;
run;


    proc logistic data=new;
        model event= A B int;
    run;

 

I've tried this:

 

data new;
set have;

x='B1';
call symput('var',x);
int=A*&var ;
run;

    proc logisitc data=new;
        model event = &var A int;
    run;

 

However, I seem to get different results if I run the same program twice.

2 REPLIES 2
Astounding
PROC Star

Assuming that LOGISTIC has no options to simplify the task, you can create the interactions without using macros:

 

data want;

   set have;

   array original {10} B1-B10;

   array inters    {10} inter_1 - inter_10;

   do _k_=1 to 10;

      inters{_k_} = A * original{_k_};

   end;

run;

 

proc logistic data=want;

   model event = A B1-B10 inter_1 - inter_10;

run;

 

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
  • 2 replies
  • 1154 views
  • 1 like
  • 3 in conversation