In descriptive statistics, we generally use PROC FREQ to summarize frequency count for the categorical variables, such as Age Group(<=65, >65), SEX(female, male), RACE(Black, White, Asian), and patient Histology. If we want to look at some specific values, I use PROC SQL to select the desired categories. Normally, we write a macro for Proc Freq then manipulate or change the variables for the desired outputs.
%macro freq(in= , var= , out1= );
proc freq data=&in noprint ;
tables strtdose*&var /out=&out1 nopercent;
%freq(in=adsl1, var=agegrpc, out1=a2);
%freq(in=adsl1, var=sex1, out1=a3);
However, the previous example is build for produce the frequency for different variables, what if we need to producing the frequency count for same variable but different cycles?
In oncology studies, the Response variable is one of the most important efficacy endpoints, we would like to use Proc Freq to produce a table to show the response result for patients in each cycle.
1. we will write a Proc Freq with a definite variable: Response, but make the cycle as a macro variable
2. we will write a macro do loop outside the proc freq to generate the cycles we need.
3. use Set statement to combine all the frequency count for each cycle.
%do i=1 %to 50;
proc freq data=pe3(where=(cycle=&i)) noprint ;
tables trtan*response /out=out&i nopercent;
proc sort; by sorter response;
Happy SAS coding 🙂 !