I am new to Stata and I am trying to recode two continuous variables into one categorical(3 categories) variable. I pasted data from dataex below. The continuous variables are "vigmin" and "modmin"(see definition below).

Vigmin = the number minutes someone participated in vigorous activity in a week

Modmin = the number minutes someone participated in moderate activity in a week

“.” = the period is treated as 0 minutes of activity, so any “.” should equal “poor(3).

Desired categories for the new categorical variable:

Ideal(1) = 150 minutes or greater of moderate physical activity per week, or 75 minutes or greater of vigorous activity per week

Intermediate(2) = 1 – 149 minutes of moderate physical activity per week, or 1 - 74 minutes of vigorous activity per week

Poor(3) = 0 minutes of activity


This is the syntax that I tried; I did not get an error, but the numbers in my output were not accurate. Should I be using different syntax?
gen idealPA=0
replace idealPA=1 if (modmin >=150) | (vigmin >=75)
replace idealPA=2 if (modmin >=1) & (modmin <=149)
replace idealPA=2 if (vigmin >=1) & (vigmin <=74)
replace idealPA=3 if (modmin==.) | (vigmin==.)
label define idealPA 1 "ideal" 2 "intermediate" 3 "Poor"
label value idealPA idealPA
ta idealPA RCTgroup, row col chi


(example data from Dataex)

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(modmin vigmin)
105  50
  .   .
 60   .
180  30
 20   .
 60   .
 60   .
 30   .
 90   .
  .   .
  .   .
180   .
 60   .
 60   .
180   .
  .   .
 90  20
 60   .
 15  15
 30   .
 60   .
 60   .
120   .
 40   .
 60 180
 45   .
  .   .
 10   .
 90   .
 60  20
 30  35
 40   .
 30  60
 60  30
180 105
 25   .
180  60
 60 120
120  30
120   .
  .  10
120   .
120 120
 40 180
 60  30
180   .
180  20
 60   .
 25   .
180  30
 30   .
 60  60
 30   .
  .   .
150   .
 10 180
  .   .
 20  15
120   .
 30   .
 90  10
180   .
 60   .
 30  30
  .  10
 30   .
 30 180
 30   .
 60   .
 90  90
 60  10
 20  10
 20  15
 45  60
 25   .
180   .
 60 120
120  90
 15   .
 15   .
 15  10
180  60
  .   .
  .   .
 30   .
  .   .
 75   .
  .   .
  .   .
 10   .
 10   .
  .   .
  .   .
  .   .
 20  10
 10   .
  .   .
  .   .
 25   .
  .   .
end




Thanks in advance for any assistance.