I don’t think that I completely understand what you’re trying to do. Specifically, what conditional probabilities are you trying to estimate? In general, the conditional events could be placed into the proc sql statement in a where clause. Here is an example of a macro that might be used to estimate some conditional probabilities:
[pre]
data test;
input id $ cough headache vomiting fever;
datalines;
1 1 0 1 1
2 0 1 0 0
3 0 0 0 1
4 1 1 0 1
;
run;
%macro findprob(event, condition);
proc sql noprint;
select avg(&event) into:prob
from test
%if %bquote(&condition) ne %then where &condition;
;
quit;
%if %bquote(&condition) ne %then %let condition = %str( )given &condition;
%let prob=&prob;
%put The probability of &event&condition is &prob..;
%mend;
options nonotes;
%findprob(cough)
%findprob(cough, vomiting)
%findprob(cough and headache)
%findprob(cough, headache and fever)
%findprob(cough and fever, not vomiting)
%findprob(fever, cough or headache)
[/pre]
The following appears on the log when the program is run:
[pre]
396 %findprob(cough)
The probability of cough is 0.5.
397 %findprob(cough, vomiting)
The probability of cough given vomiting is 1.
398 %findprob(cough and headache)
The probability of cough and headache is 0.25.
399 %findprob(cough, headache and fever)
The probability of cough given headache and fever is 1.
400 %findprob(cough and fever, not vomiting)
The probability of cough and fever given not vomiting is 0.333333.
401 %findprob(fever, cough or headache)
The probability of fever given cough or headache is 0.666667.
[/pre]
... View more