Background: I have a categorical variable, X, with four levels that I fit as separate dummy variables. Thus, there are three total dummy variables representing x=1, x=2, x=3 (x=0 is baseline).
Problem/issue: I want to be able to calculate the value of a linear combination (i.e. using SAS as a calculator) of these dummy variables. For example, 2*B1 + 2*B2 + B3.
In Stata, this can be done using the lincom
command, which uses the stored beta estimates to calculate linear combinations of the parameters.
In SAS in a procedure such as PROC GLM, I think I should use the ESTIMATE
statement, but I'm not sure how I would specify the "weights" for each variable in this case.
FYI,
PROC MODEL
does allow this in the model statement, which may be less work thanPROC SCORE
. I knowPROC MODEL
can be used readily in place ofPROC REG
, but I'm not sure how advanced of modelingPROC MODEL
does, so it may not be an option for more complex models. I was hoping for something with less coding, but given the nature of SAS, I think this andPROC SCORE
are the best I'm going to get.What if you add your linear combination as a variable in your input dataset?
then you can specify LinComb as one of the explanatory variables and you can lookup the coefficient directly from the output.
You are looking for PROC SCORE. This takes output regression or factor estimates and scores a new data set. See here for an example. http://support.sas.com/documentation/cdl/en/statug/66859/HTML/default/viewer.htm#statug_score_examples02.htm