I'm working with crossectional test data with a selection of test results (all continuous variables) in both a patient and healthy control (HC) group. I have made separate variables for the two groups' test results e.g. test1_controls, test1_patients, test2_controls, test2_patients etc. There are 95 patients and 48 healthy controls. I've attached the data for test 1.
In order to compare the patient group to the healthy control group I want to make a new variable for each test with z-scores; generating a new value for each patient comparing them to the mean of the HC group so I can see how far above or below the "normal" data they fall. So if the test 1 z-score for patient number 1 was -2.3 that would mean they were 2.3 standard deviations below the mean of the healthy control group data for that test. What code would you use for this?
I can do a generate a standardized value using egen test1_patients_z = std(test1_patients)
but these standardized values are only based on the mean and SD of the patient group and I haven't been able to find any options that give me the result I need comparing to the healthy control mean.
I tried egen test1_patients_z = std(test1_patients), mean(#) std(#)
with # being manually entered mean and SD of test1_controls (which I got by codebook) but that did not work (it just shifted the whole scale upwards by the HC mean rather than the normal z score mean of 0).
Thanks for your help!
Related Posts with Generating a new variable with standardized values compared to a healthy control group mean and SD (z scores)
Help via mergeI have 2 datasets: HEIGHT AGE SCORE x z x y HEIGHT AGE Controls x z x x y x Ho…
Create a rate variable for population as a whole with sample weightsDear Stata users, I am new to stata and am working on a dataset with 20 mio. people for two years w…
Changing Label Code in LabelHey everyone, I have received a data set where the sender incorrectly assigned the wrong codes for …
Mixed frequency in panal data Hello sir, in my panel data dependent variable is monthly excess return but independent variables …
Adding suffix or prefix to each element of a global varlistHello, I have a core set of variables and for each of them I generated several secondary variables.…
Subscribe to:
Post Comments (Atom)
0 Response to Generating a new variable with standardized values compared to a healthy control group mean and SD (z scores)
Post a Comment