DATA Step, Macro, Functions and more

Need help creating a 4-Way Venn Diagram

Reply
Occasional Contributor
Posts: 19

Need help creating a 4-Way Venn Diagram

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

Super User
Posts: 5,504

Re: Need help creating a 4-Way Venn Diagram

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.

Super User
Posts: 19,789

Re: Need help creating a 4-Way Venn Diagram

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;

Super Contributor
Posts: 256

Re: Need help creating a 4-Way Venn Diagram

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

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