BookmarkSubscribeRSS Feed
PICKME
Calcite | Level 5

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. 

 

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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:

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

So we can run code against it. 

Ksharp
Super User
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;


hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1403 views
  • 0 likes
  • 3 in conversation