The _OBSTAT_
variable is often used in conjunction with a SAS procedure to analyze observations that satisfy certain criteria. For example,
you might want to perform a linear regression only on observations that have the Include in Analysis property. Or you might
want to compute a correlation matrix only for observations that are represented by a square marker shape.
The _OBSTAT_
variable contains information about the state of observations in SAS/IML Studio. It is often convenient to use the DATA step
to split the single _OBSTAT_
variable into several indicator variables so that it is easier to use a WHERE clause to choose only observations that have
a desired property.
To use the _OBSTAT_
variable to select observations for analysis by a SAS procedure:
Create an _OBSTAT_
variable by selecting from the variable menu.
Save the augmented data to a SAS data set such as SASUSER.MyData
.
Use the following DATA step to extract each observation property into its own variable:
/* Create numerical variables from an _OBSTAT_ variable. */ data MyData; set sasuser.MyData; ObsIsSelected = inputn(substr(_obstat_, 1, 1), 1.); ObsIsInPlots = inputn(substr(_obstat_, 2, 1), 1.); ObsIsInAnalysis = inputn(substr(_obstat_, 3, 1), 1.); ObsIsLabeled = inputn(substr(_obstat_, 4, 1), 1.); ObsMarkerShape = inputn(substr(_obstat_, 5, 1), 1.); ObsMarkerRed = inputn(substr(_obstat_, 6, 5), 5.); ObsMarkerGreen = inputn(substr(_obstat_, 11, 5), 5.); ObsMarkerBlue = inputn(substr(_obstat_, 16, 5), 5.); run;
Use a WHERE clause to analyze only observations with a given set of properties. For example, the following statements compute a correlation matrix for observations that are represented in SAS/IML Studio by a marker shape:
data Subset; set MyData(where=(ObsMarkerShape=1); run; proc corr data=Subset(drop=Obs:); run;