DATAFILTER Keyword (GGRAPH command)

The DATAFILTER keyword filters values of categorical variables in the data that are used to generate the chart. Any categorical (nominal or ordinal) numeric or string variable from the active dataset can be specified on DATAFILTER. The filter applies only to the data that are used to generate the chart and does not affect the active dataset.

  • You can specify multiple variables on the DATAFILTER keyword but a particular variable can be specified only once.
  • Variables that are specified on the DATAFILTER keyword do not support ALL and TO.
  • String values do not need to be quoted, unless the string contains apostrophes or quotation marks. In addition, the string value ALL must be quoted if it is used as the value of a variable. If the string contains apostrophes or single quotation marks, then enclose the string in double quotation marks. If the string contains double quotation marks, then enclose the string in single quotation marks.
  • For variables that are not specified on DATAFILTER, all values are included.
  • DATAFILTER honors measurement level settings that are specified on the VARIABLES keyword.
VALUES
The VALUES keyword, which is required, specifies a blank-separated list of values (from the associated variable) to include or the keyword ALL.
  • If ALL is specified and UNLABELED=INCLUDE, only values without value labels are included.
  • If ALL is specified and UNLABELED=EXCLUDE, only values with value labels are included.
UNLABELED
The UNLABELED keyword specifies the handling of values that do not have value labels. The value INCLUDE, which is the default, specifies that any unlabeled values of the variable that are not specified on the VALUES keyword are included. The value EXCLUDE specifies that any unlabeled values of the variable that are not specified on the VALUES keyword are excluded.

Example

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=jobcat MEAN(salary)[name="MEAN_salary"] 
    MISSING=LISTWISE REPORTMISSING=NO DATAFILTER=jobcat(VALUES=1 2)
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: jobcat=col(source(s), name("jobcat"), unit.category())
  DATA: MEAN_salary=col(source(s), name("MEAN_salary"))
  GUIDE: axis(dim(1), label("Employment Category"))
  GUIDE: axis(dim(2), label("Mean Current Salary"))
  GUIDE: text.title(label("Simple Bar Mean of Current Salary by Employment Category"))
  SCALE: cat(dim(1), include("1", "2"))
  SCALE: linear(dim(2), include(0))
  ELEMENT: interval(position(jobcat*MEAN_salary), shape.interior(shape.square))
END GPL.