As far as I can understand the query is how to find group coefficients in a single regression model, where some independent variables may be dependent on group (M/F, let us say). In this case you need to create n dummy binary variables (for n groups) as separate independent variables. These variables will have the values 1 for all individual observations of their respective group, and 0 values for all other observations. Now these dummy variables will be multiplied with each independent variable and included in the linear regression model.
E.g. Lets say your model is: (Y = C + A.x1 + B.x2) and we have 2 groups.
We will create 2 dummy variable, z1 and z2. z1/z2 is a binary variable with value =1 for all observations in the respective group and rest values will be 0.
Now input your linear regression model as:
Y = C + A1.x1.z1 + A2.x1.z2 + B1.x2.z1+ B2.x2.z2
A1, A2 will respectively, the coefficients for groups 1 and 2