BookmarkSubscribeRSS Feed
lisahoward
Calcite | Level 5

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 0 replies
  • 3170 views
  • 0 likes
  • 1 in conversation