Please help me with the relevant command. I want to create a new variable that is equal to 1 if Moved_1 is equal to 2 and is STATE is the same as ADDRESS_YR1
My data is as follows:-.
I use the following code
But i keep getting the error MOVED_1 is an invalid name.
Can anyone please help me figuring out the right code to correct the error?
Thanks
My data is as follows:-.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte MOVED_1 long STATE byte ADDRESS_YR1 77 1 77 1 1 1 1 1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 end label values MOVED_1 MOVED_1 label def MOVED_1 1 "No", modify label def MOVED_1 2 "Yes,within australia", modify label def MOVED_1 77 "something else", modify label values STATE STATE label def STATE 1 "NSW", modify label values ADDRESS_YR1 ADDRESS_YR1 label def ADDRESS_YR1 1 "NSW", modify label def ADDRESS_YR1 77 "something else", modify
I use the following code
Code:
gen INSTATE=1 if ( MOVED_1 =2 & STATE=ADDRESS_YR1)
Can anyone please help me figuring out the right code to correct the error?
Thanks
Comment