For a specified model, there are several procedures that allow you to save the columns of the design matrix as variables in a SAS data set. PROC LOGISTIC with the OUTDESIGN= and OUTDESIGNONLY options is the most efficient for models without random effects using any coding scheme (parameterization), but PROC GLMSELECT additionally provides macro variables containing the names of all design variables created in the OUTDESIGN= data set. These macro variables are convenient for use in subsequent analyses. Use PROC GLIMMIX with the OUTDESIGN= option if the model includes random effects and you want to save the design matrix for the random effects. See also SAS Note 40631 about the OUTDESIGN= option in PROC GLIMMIX.
Specify your model in the MODEL statement and identify any categorical predictors in the CLASS statement. Note that GLMMOD and GLIMMIX offer only GLM parameterization of CLASS variables. The GLM statements below fit the indicated model and the GLMMOD and GLIMMIX statements that follow use the same design matrix as PROC GLM but also save it in a data set. With GLMMOD, the data set contains the response variable and the coded design variables. The names of the coded design variables concatenate the variable name and the variable level separated by an underscore. With GLIMMIX, the data set contains all input data set variables (unless OUTDESIGN(NOVAR) is specified) and all design variables. The names of the coded design variables are _X1, _X2, _X3, and so on for the fixed effects and _Z1, _Z2, _Z3, and so on for the random effects. A prefix other than _X or _Z can be specified using the OUTDESIGN(X=prefix Z=prefix) option. Use the ID statement to include the response variable (or other variables) in the data set. When only the design matrix is needed, it is most efficient to add the NOFIT option in the PROC GLIMMIX statement to prevent the procedure from fitting the model.
proc glm data=a; class a b c; model y=a b c a*b; run; proc glmmod data=a outdesign=xmatrix; class a b c; model y=a b c a*b; run; proc glimmix data=a outdesign(novar)=xmatrix nofit; class a b c; model y=a b c a*b; id y; run;
Each of the GLMSELECT and LOGISTIC steps below creates a data set containing the same design matrix as produced above by PROC GLMMOD (and as used internally by PROC GLM). With both procedures, the saved data set contains only the response variable and the coded design variables. To include other variables, specify them as predictors in the MODEL statement. Note that the OUTDESIGNONLY option in PROC LOGISTIC prevents the analysis, which makes it particularly efficient for this purpose regardless of the distribution of the response. The variable names created by PROC LOGISTIC for the coded design variables concatenate the variable name and the variable level for the most common parameterizations.
In PROC GLMSELECT, the SELECTION=NONE option requests that the procedure fit the specified model rather than use a model selection method. By default, variable names created by PROC GLMSELECT for the coded design variables concatenate the variable name and the variable level separated by an underscore for the most common parameterizations. See the GLMSELECT documentation for the suboptions available in the OUTDESIGN= option. GLMSELECT automatically produces several macro variables that contain the names of the created design variables. The %PUT statement below displays the contents of those macro variables. See the description of the MAXMACRO= option in the GLMSELECT documentation for more details.
proc logistic data=a outdesign=xmatrix outdesignonly; class a b c / param=glm; model y=a b c a*b; run; proc glmselect data=a outdesign=xmatrix; class a b c / param=glm; model y=a b c a*b / selection=none; run; %put _user_;To use other coding methods, specify them as needed in the CLASS statement. For example, these statements use effects coding for the CLASS variables:
proc logistic data=a outdesign=xmatrix outdesignonly; class a b c / param=effect; model y=a b c a*b; run;See the LOGISTIC and GLMSELECT documentation for information about the various coding methods that are available.
proc transreg data=a design; model class(a b c a*b / zero=none); id y; output out=xmatrix; run;Effects coding can be done as follows:
proc transreg data=a design; model class(a b c a*b / effects); id y; output out=xmatrix; run;Note that PROC TRANSREG automatically creates a macro variable, _trgind, which contains a list of variable names that it creates. You can use this macro variable in subsequent procedures to refer to the full model.
Product Family | Product | System | SAS Release | |
Reported | Fixed* | |||
SAS System | SAS/STAT | All | n/a |
Type: | Usage Note |
Priority: | low |
Topic: | SAS Reference ==> Procedures ==> GLMMOD SAS Reference ==> Procedures ==> TRANSREG Analytics ==> Regression Analytics ==> Analysis of Variance Analytics ==> Categorical Data Analysis SAS Reference ==> Procedures ==> LOGISTIC SAS Reference ==> Procedures ==> GLM SAS Reference ==> Procedures ==> GLMSELECT SAS Reference ==> Procedures ==> GLIMMIX |
Date Modified: | 2024-03-07 15:28:39 |
Date Created: | 2003-04-09 14:46:05 |