BookmarkSubscribeRSS Feed
Mmignon
Fluorite | Level 6

Hello 

I am pretty much novice in SAS Enterprise Guide and I am facing a problem which I cannot resolve by myself.

I wrote this code:

 

data test_new; set test;
     if a=1 or b=1 or c=1 then MI=1;

     If MI=. or MI<1 then MI=0;
run;

 

proc freq data=MI;
tables
     MI*randomisation_code/chisq;
run;

 

But when I run the code, I only get the table with MI=0.

 

Actually, I need the result for this:
              if a=1 and/or b=1 and/or c=1 then MI=1; (at least two of the variables should mach together)

 

but cannot get it to work.

I hope some of you can help me with advice what to do, in a step-by-step manner 🙂

TIA
Mmignon

2 REPLIES 2
Astounding
PROC Star

First step, run a PROC FREQ on the variables a, b, and c to be sure that you actually have the values you expect.  Your logic for creating MI depends on those, and looks like it should work.

 

A nice shortcut for the result you really want:

 

MI = (a + b + c) >= 2;

 

But that is dependent on the logic being right ... a, b, and c should be variables with values of 0 or 1 only.

Mmignon
Fluorite | Level 6

Thank you very much for the shortcut 🙂 
I found the solution by myself, but it's more elegant with your shortcut!

Sincerely
Mmignon

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 673 views
  • 1 like
  • 2 in conversation