In SAS Information Map Studio, you can create new data items based on the condition of another data item.
The CASE statement can be used in the Expression Text of a data item when IF-THEN-ELSE logic is needed.
The purpose of this sample is to show two of the many ways that you can utilize CASE syntax in SAS Information Map Studio.
SAS Information Map Studio Guide 4.2 was used to create this sample. This sample can also be used in SAS Information Map Studio 3.1.
The CLASS and SHOES data sets from the SASHELP library are used in this sample. To create the Shoe Sales information map and the Class information map used in the sample, you can submit the PROC INFOMAPS code on the Full Code tab in this sample. The steps in the sample refer to these information maps.
The first example includes detailed steps for creating a new data item in SAS Information Map Studio.
The second example includes only the CASE syntax that is required to achieve the particular goal.
This example creates a new category data item called TEEN, and assigns a value of 'Pre-Teen' to the new TEEN column if the AGE column is less than or equal to 12, and assigns a value of 'Teen' to the new TEEN column if the AGE column is greater than or equal to 13 and less than or equal to 19, and assigns a value of 'Other' if the AGE column has a value greater than 19. The If-Then-Else method that describes this is:
if age <= 12 then teen = 'Pre-Teen' else if age >=13 and age <= 19 then teen = 'Teen' else teen = 'Other'
case when CLASS.Age <= 12 then 'Pre-Teen'
when (CLASS.Age >= 13) and (CLASS.Age <= 20) then 'Teen'
else 'Other'
end
|
This example uses the SASHELP.SHOES data set and can be used to create a new column that assigns a value to the new column depending on the range of SHOES.Sales. As you did for Example 1, you enter this expression into the Expression Text box for the new data item.
case when (SHOES.Sales between 0 and 49999.99) then 'Needs work'
when (SHOES.Sales between 50000 and 99999.99) then 'Good work'
when (SHOES.Sales between 100000 and 174999.99) then 'Really good work'
when (SHOES.Sales >= 175000) then 'Ask for a raise!'
else 'Further review is required'
end
|
For other case statement examples, see SAS Note 32160 and SAS Note 33312.
For more information about SAS Information Map Studio, see the SAS Information Map Studio documentation page.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
Before submitting this code, these tasks must be done:
Note: For information about registering libraries and tables, see the SAS 9.2 Intelligence Platform: Data Administration Guide.
* Shoe Sales Information Map Code
%let mpath=/Shared Data/your-map-folder;
proc infomaps metauser="your-userID"
metapass="your-password"
metaserver="your-metadata-server.com"
metaport=8561
metarepository=Foundation
mappath="&mpath";
* delete infomap "Shoe Sales";
open infomap "Shoe Sales";
insert datasource sasserver="SASApp"
table="SASHELP"."Shoes" _all_;
save;
* list _all_;
run;
* Class Information Map Code
%let mpath=/Shared Data/your-map-folder;
proc infomaps metauser="your-userID"
metapass="your-password"
metaserver="your-metadata-server.com"
metaport=8561
metarepository=Foundation
mappath="&mpath";
* delete infomap "Class";
open infomap "Class";
insert datasource sasserver="SASApp"
table="SASHELP"."Class" _all_;
save;
* list _all_;
run;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
Type: | Sample |
Date Modified: | 2010-01-19 10:28:39 |
Date Created: | 2010-01-08 11:29:23 |
Product Family | Product | Host | Product Release | SAS Release | ||
Starting | Ending | Starting | Ending | |||
SAS System | SAS Information Map Studio | Windows Vista | 4.2 | 9.2 TS2M0 | ||
Microsoft Windows XP Professional | 4.2 | 9.2 TS2M0 | ||||
Microsoft Windows Server 2003 Standard Edition | 4.2 | 9.2 TS2M0 | ||||
Microsoft Windows Server 2003 Enterprise Edition | 4.2 | 9.2 TS2M0 | ||||
Microsoft Windows Server 2003 Datacenter Edition | 4.2 | 9.2 TS2M0 | ||||
Microsoft® Windows® for x64 | 4.2 | 9.2 TS2M0 |