BookmarkSubscribeRSS Feed
kalbo
Obsidian | Level 7

Hi all I have AE data which is structured like:

 

Arm  Preferred_term

A    Headache

A    Zoster

B    Fatigue

B   Headache

 

I want to use proc freq to create a data set containing risk difference (comparing Arm A and Arm B) like this:

 

Arm  Preferred_term Risk_diff

A    Headache  0.45

A    Zoster         0.5

B    Fatigue      0.1

B   Headache   0.2

 

How do I structure the data prior to using proc freq?

 

Thanks.

2 REPLIES 2
ballardw
Super User

Relative risk and risk difference in Proc freq data structure would be basically one of two forms.

Summarized data would have a risk variable with two levels (had/did not have exposure or risk) outcome (did/did not have outcome) and a count of cases. The count variable would be used as WEIGHT variable in Proc Freq.

An example of this data appears in the Example section of Proc Freq in "Analysis of a 2x2 Contigency Table".

as:

data FatComp;
   input Exposure Response Count;
   label Response='Heart Disease';
   datalines;
0 0  6
0 1  2
1 0  4
1 1 11
;

The other structure would be person/case level data where each observation is one case and just has the Exposure and Response.

 

I might guess that your outcome or response is "have headache"/"do not have headache"   "have zoster/do not have zoster". 

I really hesitate to guess what your exposure or actual risk might be though. "Arm" sounds very unlikely to be a risk. So I suspect we are missing some details.

Ksharp
Super User
If you want to calculate risk difference, you need 2x2 contingency table.
Assuming row variable is ARM which have two levels (A and B),
But the column variable ( Preferred_term ) have four levels,
Therefore you are NOT able to get risk diff.

Better give an example to illustrate how to calculate risk diff.

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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