SMPLIF

Options     Examples

SMPLIF is used to select a sample of observations based on the values of an expression. The observations in the current sample for which the expression is true are selected.

SMPLIF (PRINT, SILENT) expression ;

Usage

SMPLIF is simply followed by an expression. This expression can be a series, such as a dummy variable, or it can involve several series with logical operators. The expression is used to select observations from the current sample in the following way: if the value of the expression for an observation is greater than zero, the observation is kept, otherwise it is dropped. The resulting SMPL vector replaces the previous one.

Note that SMPLIF, unlike SMPL, chooses only observations within the current sample; you should reset the sample to cover the whole data set if you want to select a different group of observations later. Successive SMPLIFs will nest within each other, resulting in a non-increasing set of observations. Use SELECT for non-nested observation selection.

If the expression is false for all current observations, an empty sample would result. @NOB is stored as zero for this case, but the sample is left unchanged. @NOB should be tested when empty samples are possible.

Output

SMPLIF produces the same output as SMPL: the resulting sample is printed if printing has not been suppressed and the variables @SMPL and @NOB are stored in data storage.

Options

PRINT/NOPRINT prints the full set of sample pairs resulting from SMPLIF. Normally only one line is printed.

SILENT/NOSILENT prints no output at all.

Examples

Delete the first observation for every individual in a panel data set which has six years of data for each of 20 people:

SMPL 1 120 ;

TREND(PERIOD=6) YEAR;

SMPLIF YEAR > 1 ;

This example shows how logical expressions can be used to select data for estimation:

SMPLIF P>0 & R>0 & DER<ELAG ;