| Example: Using the INFOMAPS Procedure and the Information Maps Engine |
Once the tables are registered in the metadata repository, you can create a new information map. The INFOMAPS procedure inserts multiple data sources and data items, inserts relationships to join the tables, inserts four filters, and then saves the new information map.
The following code creates the new information map:
/* Create a new information map using the INFOMAPS procedure. */ proc infomaps mappath="&infomap_path"; /* Open a new information map. */ new infomap "Employee Info" auto_replace=yes; /* Insert a data source and three data items using the COLUMNS= option. */ insert datasource sasserver="SASApp" table="HR".empinfo columns=("JobCode" "LOCATION" "DIVISION") id="Empinfo"; /* Insert a data item based on a physical column. Because the ID= option */ /* is not specified, a note with its ID value will print in the SAS log. */ insert dataitem column="Empinfo".idnum classification=category; /* Insert a data item with an expression. */ insert dataitem expression="SUBSTRN(<<root.Jobcode>>, 1, 3)" type=character name="Department Code" id="Dept_code"; /* Insert a second data source, plus a data item into the */ /* current information map. */ insert datasource sasserver="SASApp" table="HR".jobcodes columns=( "TITLE" ) id="Jobcodes"; /* Insert a third data source into the current information map. */ insert datasource sasserver="SASApp" table="HR".salary id="Salary"; /* Add joins between the tables. */ insert relationship left_table="Empinfo" right_table="Jobcodes" join=inner condition="(<<Empinfo.JOBCODE>>=<<Jobcodes.JOBCODE>>)"; insert relationship left_table="Empinfo" right_table="Salary" join=inner condition="(<<Empinfo.IDNUM>>=<<Salary.IDNUM>>)"; /* Insert a folder and additional business items. */ insert folder "Salary Info"; insert dataitem column="Salary".salary name="Annual Salary" folder="Salary Info"; insert dataitem expression="<<Salary.SALARY>>/12" type=numeric name="Monthly Salary" folder="Salary Info"; insert dataitem column="Salary".enddate folder="Salary Info"; /* Insert filters. */ insert filter "Status is Current" condition="<<root.Enddate>> IS NULL" folder="Salary Info"; insert filter "Education and Publications" condition="SUBSTRN(<<root.Jobcode>>, 1, 3) IN ('EDU','PUB')" desc="Employees in Education and Publications"; insert filter "Host Systems Development" condition=" <<root.Division>>='HOST SYSTEMS DEVELOPMENT' " desc="Employees in Host Systems Development"; insert filter "Cary HQ" condition=" <<root.Location>>='Cary' " desc="Located in Cary, North Carolina HQ"; /* List all of the filters defined in the current information map. */ list filters; /* Save the information map. */ save; /* End the INFOMAPS procedure. */ quit;
Note: If you run the INFOMAPS procedure code more than once,
your output will be different from what is shown. ![[cautionend]](../../../../common/61991/HTML/default/images/cautend.gif)
Log for the INFOMAPS Procedure
25 /* Create a new information map using the INFOMAPS procedure. */
26 proc infomaps mappath="&infomap_path";
27
28 /* Open a new information map. */
29 new infomap "Employee Info"
30 auto_replace=yes;
31
32 /* Insert a data source and three data items using the COLUMNS= option. */
33 insert datasource sasserver="SASApp"
34 table="HR".empinfo
35 columns=("JobCode" "LOCATION" "DIVISION")
36 id="Empinfo";
37
38 /* Insert a data item based on a physical column. Because the ID= option */
39 /* is not specified, a note with its ID value will print in the SAS log. */
40 insert dataitem column="Empinfo".idnum classification=category;
NOTE: A data item was inserted for the physical column Empinfo.IDNUM.
The data item's ID is "Identification Number".
41
42 /* Insert a data item with an expression. */
43 insert dataitem expression="SUBSTRN(<<root.Jobcode>>, 1, 3)"
44 type=character
45 name="Department Code"
46 id="Dept_code";
47
48 /* Insert a second data source, plus a data item into the */
49 /* current information map. */
50 insert datasource sasserver="SASApp"
51 table="HR".jobcodes
52 columns=( "TITLE" )
53 id="Jobcodes";
54
55 /* Insert a third data source into the current information map. */
56 insert datasource sasserver="SASApp"
57 table="HR".salary
58 id="Salary";
59
60 /* Add joins between the tables. */
61 insert relationship
62 left_table="Empinfo"
63 right_table="Jobcodes"
64 join=inner
65 condition="(<<Empinfo.JOBCODE>>=<<Jobcodes.JOBCODE>>)";
NOTE: A relationship between the tables "Empinfo" and "Jobcodes" has
been inserted. The relationship's ID is "JOIN_10".
66
67 insert relationship
68 left_table="Empinfo"
69 right_table="Salary"
70 join=inner
71 condition="(<<Empinfo.IDNUM>>=<<Salary.IDNUM>>)";
NOTE: A relationship between the tables "Empinfo" and "Salary" has been
inserted. The relationship's ID is "JOIN_11".
72
73 /* Insert a folder and additional business items. */
74 insert folder "Salary Info";
75
76 insert dataitem column="Salary".salary
77 name="Annual Salary" folder="Salary Info";
78
79 insert dataitem expression="<<Salary.SALARY>>/12" type=numeric
80 name="Monthly Salary" folder="Salary Info";
81
82 insert dataitem column="Salary".enddate folder="Salary Info";
NOTE: A data item was inserted for the physical column Salary.ENDDATE.
The data item's ID is "Enddate".
83
84 /* Insert filters. */
85 insert filter "Status is Current"
86 condition="<<root.Enddate>> IS NULL" folder="Salary Info";
87
88 insert filter "Education and Publications"
89 condition="SUBSTRN(<<root.Jobcode>>, 1, 3) IN ('EDU','PUB')"
90 desc="Employees in Education and Publications";
91
92 insert filter "Host Systems Development"
93 condition=" <<root.Division>>='HOST SYSTEMS DEVELOPMENT' "
94 desc="Employees in Host Systems Development";
95
96 insert filter "Cary HQ"
97 condition=" <<root.Location>>='Cary' "
98 desc="Located in Cary, North Carolina HQ";
99
100 /* List all of the filters defined in the current information map. */
101 list filters;
Total filters: 4
Filter name: Cary HQ
ID: Cary HQ
Folder: /
Description: Located in Cary, North Carolina HQ
Expression: <<root.Location>>='Cary'
Filter name: Education and Publications
ID: Education and Publications
Folder: /
Description: Employees in Education and Publications
Expression: SUBSTRN(<<root.Jobcode>>, 1, 3) IN ('EDU','PUB')
Filter name: Host Systems Development
ID: Host Systems Development
Folder: /
Description: Employees in Host Systems Development
Expression: <<root.Division>>='HOST SYSTEMS DEVELOPMENT'
Filter name: Status is Current
ID: Status is Current
Folder: /Salary Info
Description:
Expression: <<root.Enddate>> IS NULL
102
103 /* Save the information map. */
104 save;
WARNING: The information map "Employee Info" already exists in the
folder "/Shared Data". The information map is
being replaced.
NOTE: The information map "Employee Info" has been saved in the folder
"/Shared Data".
105
106 /* End the INFOMAPS procedure. */
107 quit;
NOTE: PROCEDURE INFOMAPS used (Total process time):
real time 18.21 seconds
cpu time 0.20 seconds
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.