hi,
I'm new at working with STATA. Currently, I face the following problem: I have given data that are organized like that:
var1 cat1 cat2
1.2 0 1
5 0 1
...
7 1 0
2.3 1 0
...
ok so I think the logic behind is easy to grasp. Now I want to subtract those values of var1 when cat1==1 from the var1 when cat2==1.
So I thought I can just generate two new variables, where I filter with an if clause, but this doesn't work, because then the content of the variables looks like that
gen test1=var1 if cat1==1
gen test2=var1 if cat2==1
test1:
.
.
...
7
2.3
...
and test2 is the complete opposite:
1.2
5
...
.
.
...
I tried with drop deleting the missing values, but then suddenly, both variables were empty. How can I subtract them properly? My overall goal is to calculate the percentage change and the standard errors of the difference. Any suggestions?
I'm new at working with STATA. Currently, I face the following problem: I have given data that are organized like that:
var1 cat1 cat2
1.2 0 1
5 0 1
...
7 1 0
2.3 1 0
...
ok so I think the logic behind is easy to grasp. Now I want to subtract those values of var1 when cat1==1 from the var1 when cat2==1.
So I thought I can just generate two new variables, where I filter with an if clause, but this doesn't work, because then the content of the variables looks like that
gen test1=var1 if cat1==1
gen test2=var1 if cat2==1
test1:
.
.
...
7
2.3
...
and test2 is the complete opposite:
1.2
5
...
.
.
...
I tried with drop deleting the missing values, but then suddenly, both variables were empty. How can I subtract them properly? My overall goal is to calculate the percentage change and the standard errors of the difference. Any suggestions?