Contributor
Posts: 57

# Standardized Differences binary categorical variable

I have been asked to calculate the Standardized difference for continuous and categorical variables.  I understand how to do it for the continuous variables but am unsure how to do it for the binary categorical variables.  This is the code I use for the continuous  variables where x and y are the means of the two variables  for the two groups Y =treated   X = Untreated :

I use proc means to get the mean for the continuous variable in the untreated and treated groups first and then run the following code:

 data Stan_Diff;

set Cohortfile;

 if Var_Type='Cont' then do;

length stddiff diff 8;

format stddiff  6.2 diff 8.4;

denomSD = sqrt((y_&varname_Treat**2 + x_&varname_UnTrt**2)/2);

diff = x_&varname_Treat - y_&varname_UnTrt;

if denomSD gt 0 then do;

stddiff = 100*(nx_&varname_Treat - ny_&varname_UnTrt)/denomSD;

end;

else stddiff = .;

end;

run;

For the Binary variables I am using proc freq to get total counts and percentages not proc means.  Should I be using proc means.  I am unsure how to get the SD without creating a mean value first.

My data set looks like this:  For the continous variables Age and Medications I use proc means to produce a mean.

For the catagorical variables  Diabetes Asthma etc I use proc freq to generate the count and percentage for my output table.  So this is where I get stuck as with out a mean how do i produce the SD?

 Patient Exposure Age Medications Diabetes Asthma Smoking Osteo Fracture 1 1 50 6 1 0 1 0 1 2 1 54 4 0 0 1 0 1 3 0 42 11 0 1 1 1 1 4 1 35 0 1 1 0 1 0 5 0 70 9 1 0 1 0 1 6 0 55 12 1 1 0 1 0

The table I am trying to create looks like this:

 Before propensity score match (N=xxx) Baseline Characteristics Treated Untreated Standardized Difference (N=xx) (N=xx) Demographics Age – Mean xx.x (xx.x) xx.x (xx.x) x.xxx Number of unique medications  – Mean xx.x (xx.x) xx.x (xx.x) x.xxx Baseline Comorbidities Diabetes– count (%) xx.x (xx.x) xx.x (xx.x) x.xxx Asthma – count (%) xx.x (xx.x) xx.x (xx.x) x.xxx Smoking – count (%) xx.x (xx.x) xx.x (xx.x) x.xxx Osteoporosis – count (%) xx.x (xx.x) xx.x (xx.x) x.xxx Fracture – count (%) xx.x (xx.x) xx.x (xx.x) x.xxx