Hello all,

apologies if this is a silly Q but I am a very newbie in Stata and just learning it!

I wish to use the following commands :

gen month=month(date)
gen year=year(date

gen order_month=01 if month==03 & year==2016
replace order_month=02 if month==04 & year==2016
replace order_month=03 if month==05 & year==2016


I've used the: gen month=month(date) & gen year=year(date) to generate the month and year but when I am trying to use the rest ones I get an error R(109) saying :

" In an expression, you attempted to combine a string and numeric
subexpression in a logically impossible way. For instance, you
attempted to subtract a string from a number or you attempted
to take the substring of a number."

the month variable is a str2 type and the year str4 type if that helps.

I don't know what I am doing wrong and how to resolve it.

Apologies again if this is a silly Q. If anyone wishes to spend some time and help me I really appreciate it.

thank you,
Maria