Programming the statistical procedures from SAS

Standardized Differences binary categorical variable

Reply
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?

PatientExposure AgeMedicationsDiabetesAsthmaSmokingOsteoFracture
1150610101
2154400101
30421101111
4135011010
5070910101
60551211010

The table I am trying to create looks like this:

Before propensity score match
(N=xxx)
Baseline CharacteristicsTreatedUntreatedStandardized 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

Many thanks in advance,

Lisa.

Ask a Question
Discussion stats
  • 0 replies
  • 607 views
  • 0 likes
  • 1 in conversation