BookmarkSubscribeRSS Feed
gstullo
Obsidian | Level 7

Hello everyone,

I searched the internet and found this paper on creating a 4-way Venn in sas: http://www2.sas.com/proceedings/forum2008/073-2008.pdf

Problem is that I get stuck trying to get this to work.  Specifically, there are errors in the

/*************************** 4 Way Venn Diagram *********************************/

%IF &venn_diagram = 4 %THEN

%DO;

/* Counting the overlap */

data data_reformatted2;

set data_reformatted;

if A ne . and B ne . and C ne . and D ne . then do;

if A &cutoff and B &cutoff and C &cutoff and D &cutoff then ABCD = 1;

else ABCD = 0;

end;

if A ne . and B ne . and C ne . then do;

if A &cutoff and B &cutoff and C &cutoff and ABCD ne 1 then ABC = 1;

else ABC = 0;

end;

section where it says that the %IF is in open code and won't work.  There are other problems later on.

I'm new to all this and am not sure if the code in this paper can be cut-and-pasted to have it work and then work in reverse to change it for my own needs.

Could anyone assist me with some working code?

It could even be simple were I have the numbers for each group already.

There has got to be a simple way to do this!

I wish Google Charts supported 4-way Venns...

Thanks,

GST

3 REPLIES 3
Astounding
PROC Star

The simplified version of the answer is that you have to define a macro and then call it.  For example:

%macro mymacro;

   *** put all of your code here;

%mend mymacro;

%mymacro

The error you are getting is saying that %IF / %THEN statements must be enclosed within a macro definition.

Good luck ... can't really tell how close or far you are from your goal at this point.

Reeza
Super User

I think you might need to wrap this code in a macro, but I haven't looked at it thoroughly.

You could always contact the author of the paper for the macro.

You also need to have the same variable names a Kriss does

%macro venn_four();

...all the code...

%mend;

djrisks
Barite | Level 11

Hello GST,

Firstly, thank you to Astounding and Reeza for trying to help out. GST have you got this working now? Also the full source code is located here:

http://www.krissharris.co.uk//Venn%20Diagrams.sas

If you have got SAS 9.3, I have updated the Venn Diagram Macro, and the plots look much better.

Many thanks,

Kriss

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 1188 views
  • 0 likes
  • 4 in conversation