Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sub analyses of a categorical variable

    Hi,
    So I have a categorical variable for baseline and discharge diagnoses. I have a secondary outcome of seeing which people (from which had a non-affective disorder at baseline) then shifted to affective disorders at discharge.
    My categorical variable for baseline and discharge include the following:
    0 - Non psychotic
    1 - Non-affective
    2 - Affective

    I want to create an outcome variable that measures this 'shift' but am unsure of how this would work. I know I have to recode so I am only using the people who have non-affective disorders at baseline but how would I create a main outcome variable to measure this. I have been using the follow command in stata:
    gen shift_affect = nonaffect_baseline == affect_discharge (*note non_affect baseline is only those with a non-affective disorder at baseline and affect_discharge is only those with affective disorders at baseline)
    However when I used this command, the numbers do not add up. If I do a simple tab of both my baseline and discharge original variables I am able to see how many people shifted from non-affective to affective and those numbers to not match the tabbed numbers for this new variable.

    Any help on how to create this outcome variable would be helpful.

    Kind regards,

  • #2
    I think you wanted something like
    Code:
    gen shift_affect = nonaffect_baseline==1 & affect_discharge==1
    or if you are certain that there are no missing values for the two variables, so that the only nonzero values represent "true" and not "missing"
    Code:
    gen shift_affect = nonaffect_baseline & affect_discharge

    Comment


    • #3
      Hi William,

      Thank you. That command does work and it shows me the correct number of those who shifted to affective disorders however it also gives me the total of everyone else in the sample not just the remaining non-affective subgroup. So there us 338 subjects who have a baseline diagnosis of non-affective disorders and I want an outcome variable that reflects that 26 of these shifted and the remainder of the 338 didn't. I am not sure why it is adding up the remainder of the whole sample

      Comment


      • #4
        I cannot see your data, I do not know what Stata commands you are running to receive the output you describe in words, and I do not understand what the output you are describing in words looks like. So I am not sure why whatever you are doing is not giving you the answer you require.

        I suggest you look at your data in Stata's Data Browser and find some of the cases for which shift_affect is including subjects is should not, and work through the calculation of shift_affect by hand and see what is causing the problem.

        Comment

        Working...
        X