Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I multiply two category variables by another category variable to create a new variable?


    Hi All,

    I want to create a new variable which is (Age * Education levels). But the problem is that the age variable and education levels variable are categories, for example, the 'Age variable' has five age groups and the 'education levels variable' has five levels of education.
    How can I multiply two category variables by another category variable to create a new variable?

    Thanks,

  • #2
    Hm:
    I'd be way better off with letting Stata -fvvarlist- notation do it for you (I assume you're interested in creating a predictor for a regression):
    Code:
    i.age##i.education_levels
    The usual cautionary tale about categorizing a continuous predictor (https://pubmed.ncbi.nlm.nih.gov/16217841) still holds.
    Last edited by Carlo Lazzaro; 05 Mar 2023, 05:54.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment

    Working...
    X