Hello
The Data: I have several binary variables indicating presence/absence of a particular health condition and I am comparing them between homeless and housed individuals. For example, the variables will be 1/0 indicating presence/absence of a diagnosis of CVD, Cancer, etc. and I am interested in the proportion with the disease in the homeless population vs the housed population.
The Problem: When I create the table it gives me the proportion of people with the disease (variable = 1) as well as the proportion of people without the disease (variable = 0). I just want it to display the proportion of people with the disease in the table. So essentially, I will have a table with 3 columns - column1 = variable name (e.g. CVD, Cancer, etc.), column 2 = proportion with the disease in homeless population, column 3 = proportion with the disease in the housed population. It's a bit more complicated than this sounds, but if I can solve this simple problem, I can get the rest to work.
Solution Needed: How can get Stata to only display the proportion when the variable = 1 using the Collect command? I can't just use an if statement in the Table command preceding it (e.g. if cancer == 1) as then it won't give me the correct proportion of people with the condition.
I hope that makes sense and I'm grateful to anyone who can help. I have many variables and multiple years of data so I don't want to fiddle around in Excel deleting rows.
Serena
p.s. I have the Table/Collect commands working fine apart from this one issue. Unfortunately I can't copy my code as I am analysing my data in a secure data safe haven.
The Data: I have several binary variables indicating presence/absence of a particular health condition and I am comparing them between homeless and housed individuals. For example, the variables will be 1/0 indicating presence/absence of a diagnosis of CVD, Cancer, etc. and I am interested in the proportion with the disease in the homeless population vs the housed population.
The Problem: When I create the table it gives me the proportion of people with the disease (variable = 1) as well as the proportion of people without the disease (variable = 0). I just want it to display the proportion of people with the disease in the table. So essentially, I will have a table with 3 columns - column1 = variable name (e.g. CVD, Cancer, etc.), column 2 = proportion with the disease in homeless population, column 3 = proportion with the disease in the housed population. It's a bit more complicated than this sounds, but if I can solve this simple problem, I can get the rest to work.
Solution Needed: How can get Stata to only display the proportion when the variable = 1 using the Collect command? I can't just use an if statement in the Table command preceding it (e.g. if cancer == 1) as then it won't give me the correct proportion of people with the condition.
I hope that makes sense and I'm grateful to anyone who can help. I have many variables and multiple years of data so I don't want to fiddle around in Excel deleting rows.
Serena
p.s. I have the Table/Collect commands working fine apart from this one issue. Unfortunately I can't copy my code as I am analysing my data in a secure data safe haven.
Comment