Help using Base SAS procedures

How to get number of patients in each adverse event? Proc Tabulate?

Reply
N/A
Posts: 0

How to get number of patients in each adverse event? Proc Tabulate?

Hi
I need to generate output that looks like this (number of patients and number of events per each event)

# patients # events
Bleeding 10 14
Stroke 8 12
etc

How can proc tabulate help me do this? So far i only know how to get the #events per event type.

Message was edited by: sareenk Message was edited by: sareenk
Valued Guide
Posts: 2,175

Re: How to get number of patients in each adverse event? Proc Tabulate?

what is the structure of the data set you start with?
N/A
Posts: 0

Re: How to get number of patients in each adverse event? Proc Tabulate?

the structure of my dataset is that it is in long format, meaning i have multiple rows per patient with the corresponding event type.
SAS Super FREQ
Posts: 8,776

Re: How to get number of patients in each adverse event? Proc Tabulate?

A mini-sample would help. If your data looked like this:
[pre]
Patient Event Date
alan bleeding 12/10/08
alan stroke 12/12/08
alan bleeding 12/14/08
bob stroke 12/15/08
bob stroke 12/18/08
carl bleeding 12/16/08
carl stroke 12/17/08
dan bleeding 12/19/08
[/pre]

What would you expect to see?

[pre]
One possibility:
Event NumPT NumEv
Bleeding 4 4 (alan counted twice)
Stroke 4 4 (bob counted twice)

Another Possibility:
Event NumUniquePT NumEv
Bleeding 3 4 (alan counted once)
Stroke 3 4 (bob counted once)
[/pre]

Or perhaps you have other report requirements???

cynthia
N/A
Posts: 0

Re: How to get number of patients in each adverse event? Proc Tabulate?

Yes, it would need to look like the second possibility, like this:

Bleeding: #patients: 3 # bleeding events: 4
Stroke #patients: 3 # stroke events: 4

Since 4 strokes are hapening in 3 patients, and so on.
Does proc tabulate do this for me?
Currently, the way I do this is i say

data pts;
if first.patcode;
by patcode;
where event='Bleeding';
run;
etc for each event I have.
I am looking for a more concise method

Thank you
SAS Super FREQ
Posts: 8,776

Re: How to get number of patients in each adverse event? Proc Tabulate?

Hi:
With a little data "preparation", you can create the report you want with PROC TABULATE. Essentially, you need to make a numeric variable whose value will be 1 or 0 depending on whether you want to count the patient or not -- for a particular patient/event combination.

This program assumes that the events are all going to be spelled exactly the same. In other words, stroke will ALWAYS be "stroke" and not "stroke" for one obs and "strke" for another obs and "strokes" for another obs.

The new variable, COUNTTHIS, will be used as an analysis variable by PROC TABULATE. EVENT will be placed in the row dimension of the table and COUNTTHIS and N will be in the column dimension of the table.

This program assumes that the data already exists in the PT_EVENT data set.

cynthia
[pre]
proc sort data=pt_event;
by patient event;
run;

ods listing;
data uniq_pte;
set pt_event;
by patient event;
if first.event then countthis = 1;
else countthis = 0;
run;

** Print just to show result of using FIRST.EVENT;
proc print data=uniq_pte;
title 'Create Variable to Count Unique Patients for Each Event';
title2 '(Only the first event for every unique patient/event combo';
title3 'will get a 1 in order to be counted.)';
format date mmddyy10.;
run;

proc tabulate data=uniq_pte f=comma8.;
title 'Use Proc Tabulate';
class event;
var countthis;
table event all='Total',
countthis="Number Unique Patients" n="Number Events";
keylabel sum = ' ';
run;
[/pre]
N/A
Posts: 0

Re: How to get number of patients in each adverse event? Proc Tabulate?

Thank you so much for your help, it worked! If I knew this forum was so helpful I would have asked about this a few years ago!
A million thanks!
Ask a Question
Discussion stats
  • 6 replies
  • 139 views
  • 0 likes
  • 3 in conversation