Using the Examples in Your Application (GPL)

If you want to run the examples in your application, you need to incorporate them into the syntax specific to your application.

Using the Examples in IBM® SPSS® Statistics

The sample files installed with the product can be found in the Samples subdirectory of the installation directory. There is a separate folder within the Samples subdirectory for each of the following languages: English, French, German, Italian, Japanese, Korean, Polish, Russian, Simplified Chinese, Spanish, and Traditional Chinese.

Not all sample files are available in all languages. If a sample file is not available in a language, that language folder contains an English version of the sample file.

  1. First, you need the right data source. The examples use three different userSources (Employeedata, stocks, and customer_subset), which correspond to IBM SPSS Statistics SAV files located in the directory identified above.
  2. With the data source open, create a GGRAPH syntax command.
    • Modify the GRAPHDATASET subcommand by setting the NAME keyword to the id of the userSource in the GPL example. The VARIABLES keyword also needs to include all the variables identified in the GPL DATA statements.
    • Modify the GRAPHSPEC subcommand so that the SOURCE keyword equals INLINE.
  3. Follow the GGRAPH command with BEGIN GPL, the GPL shown in the example, END GPL, and a period.

So if you want to run the simple bar chart example (see Simple Bar Chart (GPL)), your syntax would look like the following:

GGRAPH
 /GRAPHDATASET NAME="Employeedata" VARIABLES=jobcat salary
 /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
SOURCE: s = userSource(id("Employeedata"))
DATA: jobcat=col(source(s), name("jobcat"), unit.category()) 
DATA: salary=col(source(s), name("salary")) 
SCALE: linear(dim(2), include(0)) 
GUIDE: axis(dim(2), label("Mean Salary")) 
GUIDE: axis(dim(1), label("Job Category")) 
ELEMENT: interval(position(summary.mean(jobcat*salary)))
END GPL.

Using the Examples in IBM SPSS Visualization Designer

  1. Create or open a visualization in IBM SPSS Visualization Designer.
  2. If the ViZml/GPL palette is not displayed, from the menus choose:

    View > Palettes > ViZml/GPL

  3. Click the GPL tab.
  4. Enter the GPL into the palette. You can also copy and paste examples from the online help.
  5. Modify the file function for csvSource to reference the full path to the CSV file. All of the sample data files are located in the data subfolder of the product installation folder. For example:
    SOURCE: s = csvSource(file("C:/Program Files/IBM/SPSS/Visualization Designer/data/Employee data.csv"))
    DATA: jobcat=col(source(s), name("jobcat"), unit.category()) 
    DATA: salary=col(source(s), name("salary")) 
    SCALE: linear(dim(2), include(0)) 
    GUIDE: axis(dim(2), label("Mean Salary")) 
    GUIDE: axis(dim(1), label("Job Category")) 
    ELEMENT: interval(position(summary.mean(jobcat*salary)))
  6. After entering and modifying the GPL, click the execute button.
Figure 1. Execute button
Execute button