difference in two commands

Hi there,

I am working with a huge database related to children performances at school.
Basically I want to know the percentage of children in private and government schools who take private tuition.
I need some help with understanding the difference between the 2 following commands:

The first command is:

bysort state : tab class tuition if chd==1 & class<9 & chsch==1 & schcode2==1 & age>=5 & age<=16 [w=iwt], row

This is the command which produces the correct results.
However, I changed it a bit as, suppose, I don't want to have the results for each single state but only for one state.

So I did:

bysort class: tab tuition schcode2 if chd==1 & chsch==1 & class <=8 & age >=5 & age<=16 & state==1 [w=iwt], row

This second command does not produce the correct results.
What is wrong in this command? I am sure I am missing something but I cannot figure out what...

Hope to hear from you!

Thanks a lot!



Ninja say what!?!
It looks like in the first command, you're cross-tabbing class and tuition by each state as long as a whole bunch of conditions are satisfied.

In the second command, you're cross-tabbing tuition and some variable named schcode2, removing that variable as a condition, and by each class.

In regards to what is "correct", I don't know what you're really asking. Both commands are obviously doing separate things. What kind of results are you supposed to get in order to have them be "correct"? To better understand what your problem is, it'd prolly be better for me to look at your data as well.
What I am trying to do is to look at the percentage of children who in each grade (class) take tuition in private and government schools.

The reason why I changed the first command to the second one is only because I did not want STATA to show me the output for each single of the 31 Indian states, but only for 1.

What I mean by results being correct, I mean that I am just trying to reproduce some tables as they appear on a book. If I run the first command, the results are 100% the same while in the second command I get wrong results.
You wrote"Both commands are obviously doing separate things". Can you please explain me why? After all I thought I was just saying to stata, do the same operation but JUST for the state==26.
But apparently I gave a total different command...can you explain me in which way the second command is so different?

sorry, the two commands produce 2 different results because the coding for state in the second command is wrong!

Sorry about that!
It makes all sense now!

Thanks again for your support!