BookmarkSubscribeRSS Feed
Obsidian | Level 7

I am creating a retention report to show the number of participants retained in research procedures month over month. In this report there are rows for each site and columns for each month. Within each row is a "sub row" for "Total Enrolled," "N expected," (people we expect back within each time period; changes since not everyone is enrolled in the same month) "N retained," (number who came back for their expected procedures) and "% retained."


Since "Total Enrolled" is not time-dependent, it would be cleaner to have enrolled as a stand-alone column (one more column total, one fewer row per site) but when I try to add it to the columns dimension much as I would with the ALL option I get the error "There are multiple analysis variables associated with a single table cell in the following nesting: site*f*____*enrolled*sum*s" where "_____" is  expected, retainedN, or retainedPCT (three total errors).


I cannot use the ALL option since the N expected will not add up to the total N enrolled (e.g., early censoring).


Hopefully this pastes, I'm trying to do something like this:

  N enrolledTime 1Time 2
Site 1Sub Denom1009267
 Sub Num 8660
 % 93.5%89.6%
Site 2Sub Denom15010474
 Sub Num 8455
 % 80.8%74.3%
TotalSub Denom250196141
 Sub Num 170115
 % 86.7%81.6%


Thanks for your help!

Super User

If you don't want to nest variable then just place them together. If you want the same statistics for each group with parentheses.


Some example data so we have variable names and types would help. At least show your  current code.


Is "Total enrolled" supposed to equal the number records? The likely you just need N without a variable BUT you will likely get it repeated as it crosses with each row.

proc tabulate data=sashelp.class;
   class sex;
   var height weight;
   table sex,
         n='Number of obs' height*mean weight*max

or provide example data:

Instructions here: will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

Obsidian | Level 7

Hi thank you for your reply.


I'm not sure what you mean by "If you don't want to nest variable then just place them together. If you want the same statistics for each group with parentheses."


Your suggestion is close to what I'm looking for but I am creating this from a summary table rather than an observation level one.


My data looks something like this, albeit with more rows:

data retainreport;
 infile datalines delimiter=',';
 input site visitcode enrolled expected retained retainedpct;
proc tabulate data=retainreport; class site visitcode / order=data; classlev site; classlev visitcode; var enrolled expected retained retainedpct; table (site='')* (enrolled*f=best12. expected*f=best12. retained*f=best12. retainedpct*f=percent6.), visitcode*(sum=''); run;



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2 in conversation