Using regression to both estimate and attribute a single value to a subset of established categories I am using Stata 15.1
I have a dataset with some 12,000 observations with a continuous dependent variable and 4 continuous independent variables. Each observation is also prior assigned to one of about 100 categories. Each category can belong to one of two cases, not known ex ante. In the first case the category represents a zero value in the regression. In the second case the category represents an unknown single value constant across the data set (for those observations with categories assigned to this second case).
I wish to combine the regression of the continuous data with an estimate of both which categories belong to which case, and what the single value is that is then common to the second case.
 A: Try this approach, which I believe is likely valid. Note: You can likely  best fine tune the proposed process (for example, starting subsample size selection,...) by constructing a test population, which conforms to the assumptions of the regression model and for which, you known, as you are generating the data, all the true underlying values.
First, select a random subset of the population for data exploration. Guess (for example, assume all equal values) the starting values for "unknown single value constant across the data set" and iteratively apply the regression to arrive at improved estimates based on values from the prior run.
For the rest of the data set, apply regression analysis, where you have now fixed the "unknown single value constant across the data set" at the values determined in the subset analysis.
As to whether this approach is effective and degree of accuracy may be determined per the simulation exercise. Note, violation of regression assumptions in your real data set, like for example, non-normal errors, should be addressed (consider a transformations analysis) so that you do not overly state the accuracy of your final estimates.
Note: Some may suggest to directly employ a more complex minimization model, however, my experience is that these are not always better as testing on your simulation model database may confirm.
