Once the tables are
registered in the metadata server, 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="SAS Sample Data".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="SAS Sample Data".jobcodes
columns=( "TITLE" )
id="Jobcodes";
/* Change the data item to a measure so that you can use it in computations */
/* and analytical expressions. Set the default aggregation to Count. */
update dataitem "Title" aggregation=COUNT classification=MEASURE;
/* Insert a third data source into the current information map. */
insert datasource sasserver="SASApp"
table="SAS Sample Data".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 a data item that contains an expression */
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 the key properties of business data in the current information map. */
list;
/* 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.
Log for the INFOMAPS Procedure
27 /* Create a new information map using the INFOMAPS procedure. */
28 proc infomaps mappath="&infomap_path";
29 /* Open a new information map. */
30 new infomap "Employee Info"
31 auto_replace=yes;
32
33 /* Insert a data source and three data items using the COLUMNS= option. */
34 insert datasource sasserver="SASApp"
35 table="SAS Sample Data".empinfo
36 columns=("JobCode" "LOCATION" "DIVISION")
37 id="Empinfo";
NOTE: A data item was inserted for the physical column "EMPINFO.JOBCODE". Its
ID is "Jobcode".
NOTE: A data item was inserted for the physical column "EMPINFO.LOCATION". Its
ID is "Location".
NOTE: A data item was inserted for the physical column "EMPINFO.DIVISION". Its
ID is "Division".
38
39 /* Insert a data item based on a physical column. Because the ID= option */
40 /* is not specified, a note with its ID value will print in the SAS log. */
41 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".
42
43 /* Insert a data item with an expression. */
44 insert dataitem expression="SUBSTRN(<<root.Jobcode>>, 1, 3)"
45 type=character
46 name="Department Code"
47 id="Dept_code";
48
49 /* Insert a second data source, plus a data item into the */
50 /* current information map. */
51 insert datasource sasserver="SASApp"
52 table="SAS Sample Data".jobcodes
53 columns=( "TITLE" )
54 id="Jobcodes";
NOTE: A data item was inserted for the physical column "JOBCODES.TITLE". Its ID is
"Title".
55
56 /* Change the data item to a measure so that you can use it in computations */
57 /* and analytical expressions. Set the default aggregation to Count. */
58 update dataitem "Title" aggregation=COUNT classification=MEASURE;
59
60 /* Insert a third data source into the current information map. */
61 insert datasource sasserver="SASApp"
62 table="SAS Sample Data".salary
63 id="Salary";
64
65 /* Add joins between the tables. */
66 insert relationship
67 left_table="Empinfo"
68 right_table="Jobcodes"
69 join=inner
70 condition="(<<Empinfo.JOBCODE>>=<<Jobcodes.JOBCODE>>)";
NOTE: A relationship between the data sources "Empinfo" and "Jobcodes" has been
inserted. The relationship's ID is "JOIN_10".
71
72 insert relationship
73 left_table="Empinfo"
74 right_table="Salary"
75 join=inner
76 condition="(<<Empinfo.IDNUM>>=<<Salary.IDNUM>>)";
NOTE: A relationship between the data sources "Empinfo" and "Salary" has been
inserted. The relationship's ID is "JOIN_11".
77
78 /* Insert a folder and additional business items. */
79 insert folder "Salary Info";
80
81 insert dataitem column="Salary".salary
82 name="Annual Salary" folder="Salary Info";
83
84 /* Insert a data item that contains an expression */
85 insert dataitem expression="<<Salary.SALARY>>/12" type=numeric
86 name="Monthly Salary" folder="Salary Info";
87
88 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".
89
90 /* Insert filters. */
91 insert filter "Status is Current"
92 condition="<<root.Enddate>> IS NULL" folder="Salary Info";
93
94 insert filter "Education and Publications"
95 condition='SUBSTRN(<<root.Jobcode>>, 1, 3) IN ("EDU","PUB")'
96 desc="Employees in Education and Publications";
97
98 insert filter "Host Systems Development"
99 condition='<<root.Division>>="HOST SYSTEMS DEVELOPMENT" '
100 desc="Employees in Host Systems Development";
101
102 insert filter "Cary HQ"
103 condition='<<root.Location>>="Cary" '
104 desc="Located in Cary, North Carolina HQ";
105
106 /* List the key properties of business data in the current information map. */
107 list;
Total datasources: 3
Data source: SAS Sample Data.EMPINFO
ID: Empinfo
Name: EMPINFO
Description:
Required data source: NO
Data source: SAS Sample Data.JOBCODES
ID: Jobcodes
Name: JOBCODES
Description:
Required data source: NO
Data source: SAS Sample Data.SALARY
ID: Salary
Name: SALARY
Description:
Required data source: NO
Total data items: 9
Data item name: Annual Salary
ID: Annual Salary
Folder: /Salary Info
Description: Physical column SALARY
Expression: <<Salary.Salary>>
Expression type: NUMERIC
Classification: MEASURE
Format: DOLLAR12.
Default aggregation: Sum
Data item name: Department Code
ID: Dept_code
Folder: /
Description:
Expression: SUBSTRN(<<root.Jobcode>>, 1, 3)
Expression type: CHARACTER
Classification: CATEGORY
Format:
Data item name: Division
ID: Division
Folder: /
Description: Physical column DIVISION
Expression: <<Empinfo.DIVISION>>
Expression type: CHARACTER
Classification: CATEGORY
Format:
Data item name: Enddate
ID: Enddate
Folder: /Salary Info
Description: Physical column ENDDATE
Expression: <<Salary.ENDDATE>>
Expression type: DATE
Classification: CATEGORY
Format: DATE9.
Data item name: Identification Number
ID: Identification Number
Folder: /
Description: Physical column IDNUM
Expression: <<Empinfo.Identification Number>>
Expression type: NUMERIC
Classification: CATEGORY
Format: SSN11.
Data item name: Jobcode
ID: Jobcode
Folder: /
Description: Physical column JOBCODE
Expression: <<Empinfo.JOBCODE>>
Expression type: CHARACTER
Classification: CATEGORY
Format:
Data item name: Location
ID: Location
Folder: /
Description: Physical column LOCATION
Expression: <<Empinfo.LOCATION>>
Expression type: CHARACTER
Classification: CATEGORY
Format:
Data item name: Monthly Salary
ID: Monthly Salary
Folder: /Salary Info
Description:
Expression: <<Salary.Salary>>/12
Expression type: NUMERIC
Classification: CATEGORY
Format: DOLLAR12.
Data item name: Title
ID: Title
Folder: /
Description: Physical column TITLE
Expression: <<Jobcodes.TITLE>>
Expression type: CHARACTER
Classification: MEASURE
Format: BEST12.
Default aggregation: Count
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
Total relationships: 2
Relationship ID: JOIN_10
Left data source: SAS Sample Data.EMPINFO
Right data source: SAS Sample Data.JOBCODES
Cardinality: UNKNOWN
Join type: INNER
Join expression: (<<Empinfo.JOBCODE>>=<<Jobcodes.JOBCODE>>)
Relationship ID: JOIN_11
Left data source: SAS Sample Data.EMPINFO
Right data source: SAS Sample Data.SALARY
Cardinality: UNKNOWN
Join type: INNER
Join expression: (<<Empinfo.Identification Number>>=<<Salary.Identification Number>>)
108
109 /* Save the information map. */
110 save;
NOTE: The information map "Employee Info" has been saved in the folder
"/Shared Data/Infomap Example".
111
112 /* End the INFOMAPS procedure. */
113 quit;
NOTE: PROCEDURE INFOMAPS used (Total process time):
real time 10.13 seconds
cpu time 0.04 seconds