SAS Enterprise Guide 7.11
Hi, I have questions.
1. I want to create a table which I want to create. but i don't know how to do. PLZ let me know 😞
original dataset :
ID A1 A2 A3 ... A91 An : disease name
-------------------------------------
1 1 1 1 0 1:disease o
2 0 1 0 1 0:disease x
.
.
.
910000 1 0 1 0
TABLE which i want to create :
disease1 disease2 count phi coefficient
-----------------------------------------------------------
A1 A2 30 0.012
A1 A3 20 0.033
:
A1 A91 100 0.223
A2 A3 40 0.111
:
A2 A91 200 0.333
:
A90 A91 100 0.445
2. I've already tried these proc steps.
proc table;
table A1*(A2-A91);
output out=a / chisq;
run;
but i don't know next steps.
and i know i have to use 'proc tamplate step' but i don't know how to do. plz help me.
Hi,
I think in your code you meant to say:
proc freq data=<dataset>; tables A1*(A2-A91); output out=a / chisq; run;
Or something similar to that. On a secondary note, proc template is used to create templates, be them style templates, graph templates or table templates. You do not *need* to use them at all, although they are helpful to get output to look a certain way.
Next up I would suggest you post test data as a datastep, follow this post:
So we can run code against it.
How do you get that COUNT variable. I also notice you want PI coefficient.
data have;
input ID A1 A2 A3 A4;
cards;
1 1 1 1 0
2 0 1 0 1
3 1 1 1 1
4 0 0 1 0
5 1 1 0 0
6 1 0 1 1
7 1 0 1 1
8 0 0 0 0
9 0 1 1 1
11 1 1 1 0
12 1 1 1 1
13 1 0 1 0
14 0 1 1 1
15 1 1 0 0
16 1 1 1 0
17 0 1 1 1
18 1 1 1 0
;
run;
data temp;
set have(drop=id);
array x{*} A:;
length vname1 vname2 $ 40;
do i=1 to dim(x);
vname1=vname(x{i});
value1=x{i};
do j=i+1 to dim(x);
vname2=vname(x{j});
value2=x{j};
output;
end;
end;
keep vname1 vname2 value1 value2;
run;
proc sort data=temp;
by vname1 vname2 value1 value2;
run;
proc freq data=temp noprint;
tables vname1*vname2/out=temp1 list;
run;
proc freq data=temp noprint;
by vname1 vname2 ;
table value1*value2/chisq;
output out=temp2 phi;
run;
data want;
merge temp1 temp2;
by vname1 vname2;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.