INFOMAPS Procedure

Example 2: Creating an Information Map with Relationships and Filters

The following example shows:
  • how to create a relationship to link two data sources
  • how to explicitly create folders with the INSERT FOLDER statement, and how to insert data items into the folders with the INSERT DATAITEM statement
  • how to create a filter that can be used in queries to subset a data item
proc infomaps metauser="your-user-ID"
   metapass="your-password"
   metaserver="your-server-name"
   metaport=8561;

   /* Open a new information map.  The specified location is */
   /* where, by default, the information map is saved when a */
   /* SAVE statement issued. The information map exists only */
   /* in memory until a SAVE statement is issued.            */
   new infomap "Employee Info" 
      mappath="/Users/sasdemo/My Folder"
      auto_replace=yes;

   /* Make the Employee Information table accessible. */
   insert datasource sasserver="SASApp"
      table="HR"."EMPINFO"
      id="EmployeeInfo";

   /* Make the Salary Information table accessible. */
   insert datasource sasserver="SASApp"
      table="HR"."SALARY"
      id="SalaryInfo";

   /* Create a relationship to link the data sources. */
   insert relationship
      id="join_empinfo_to_salary"
      left_table="EmployeeInfo"
      right_table="SalaryInfo"
      cardinality=one_to_one
       condition="<<EmployeeInfo.IDNUM>>=<<SalaryInfo.IDNUM>>";

   /* Create folders for data items. */
   insert folder "Employee Information";
   insert folder "Salary Statistics";

   /* Create data items. */
   insert dataitem
      column="EmployeeInfo"."NAME"
      folder="Employee Information";

   insert dataitem
      column="EmployeeInfo"."IDNUM"
      folder="Employee Information"
      classification=category;

   insert dataitem
      column="EmployeeInfo"."JOBCODE"
      folder="Employee Information"
      name="Job Code";

   insert dataitem
      column="EmployeeInfo"."DEPTCODE"
      folder="Employee Information"
      name="Department";

   insert dataitem
      column="EmployeeInfo"."LOCATION"
      folder="Employee Information";

   insert dataitem
      column="SalaryInfo"."SALARY"
      folder="Salary Statistics"
      name="Average Salary"
      aggregations_keep_list=("AVG")
      format="dollar12.2";

   insert dataitem
      column="SalaryInfo"."SALARY"
      folder="Salary Statistics"
      name="Minimum Salary"
      aggregations_keep_list=("MIN")
      format="dollar12.2";

   insert dataitem
      column="SalaryInfo"."SALARY"
      folder="Salary Statistics"
      name="Maximmum Salary"
      aggregations_keep_list=("MAX")
      format="dollar12.2";

   /* Create a filter for the Location data item. */
   insert filter
      name="Cary Employees" 
      description="Employees who work in Cary, NC"
      condition="<<EmployeeInfo.LOCATION>>='Cary'";

   /* Save the information map that is currently open.  Because   */
   /* no location is specified in the SAVE statement, it is saved */
   /* in the location specified in the NEW INFOMAP statement.     */
   save;

run;
The following window shows the resulting information map opened in SAS Information Map Studio.
Example information map with relationships and filters