What test to use? – two continuous variables by one categorical - Stata


Is there any way to test to see if a laboratory blood value is different between people in 2 categories while considering age? I am using Stata.

For example, here is what I have done considering a categorical variable (instead of age):

I also wanted to look at the difference in this lab value, called “RDW,” for people who had greater than 12 years of education and see if it is different between those who experienced an adverse health event and those who had not experienced it, call it “event.” I entered this in Stata:

. ttest RDW if education==1, by(event)

From this I was able to get a P value to see if RDW is different between those who experienced the event and those who did not, if both of those groups were from the education category of 1.

Variables used:

RDW = a continuous laboratory value from blood work
Education = one of two categories, greater or less than/equal to 12 years
Event = did they not have the event or did they experience the event

What test would I use to examine this if I wanted to look at age instead of education? I am guessing I would need a different test because age is continuous in this data where as education was categorized.

Thank you for at least taking a look; I appreciate any responses!