Hi,
I have a dataset containing a string variable called "Signal" that contains cells with text like SBDE, SBLM, and so on. I need to create a new variable that takes on different values depending on "Signal".
I therefore first encoded "Signal" according to:
encode Signal, generate (Signal_n)
That went fine (I could see that "Signal_n" had been given an numeric value and was blue).
I thereafter started to generate the new variable Person:
gen Person =0
replace Person = 19430724 if Signal_n == SBDE & fiskedatum == 20140101
The problem started in the last line, SBDE cant be read. I also tried with double quotes ("SBDE") but it also doesnt work.
I guess there is an easy way to fix this (I used need to understand how to write the code correctly) and would much apprecoate any hint!
Thanks!
Karin
I have a dataset containing a string variable called "Signal" that contains cells with text like SBDE, SBLM, and so on. I need to create a new variable that takes on different values depending on "Signal".
I therefore first encoded "Signal" according to:
encode Signal, generate (Signal_n)
That went fine (I could see that "Signal_n" had been given an numeric value and was blue).
I thereafter started to generate the new variable Person:
gen Person =0
replace Person = 19430724 if Signal_n == SBDE & fiskedatum == 20140101
The problem started in the last line, SBDE cant be read. I also tried with double quotes ("SBDE") but it also doesnt work.
I guess there is an easy way to fix this (I used need to understand how to write the code correctly) and would much apprecoate any hint!
Thanks!
Karin