Tuesday, November 10, 2009

Using Multiple Selection Prompts in SAS Stored Process Code

It is definitely easier to force single selections for prompts used in SAS Stored Processes, however it isn't very usable when the majority of users need to select multiple values. For example, let us say we create a prompt for region (called 'region_prompt') and then use that in the query of sashelp.shoes.

Forcing only 1 selection to write to the macro &region_prompt the resulting SQL query would look like:
     proc sql; create table test as select * from sashelp.shoes where shoes.region="&region_prompt";  
     quit;
Pretty simple really.

Now if we allow users to select 1 or more values for region, SAS creates a macro with the same name but adding the term _Count. Such as &region_prompt_count, this represents the amount of selections the user chose. Therefore the SQL query needs to take all of these selections into account. ALSO - if only 1 selection is chosen, there is no &region_prompt1 - so you must account for that as well.
Here is an example:
     proc sql; create table test as select * from sashelp.shoes
             where shoes.region in (
             %if &REGION_PROMPT_COUNT = 1 %then 
                            "&Region_Prompt";
             %else %do i=1 %to &REGION_PROMPT_COUNT;
                         "&&Region_Prompt&i"
             %end;
              );
    quit;

Reference: Overview of Input Parameters http://support.sas.com/documentation/cdl/en/stpug/61271/HTML/default/a003152642.htm

Monday, November 09, 2009

Mapping ESRI Style

The SAS Business Intelligence suite includes the ability to map data via the ESRI Map Service within various web clients (and even Enterprise Guide).



Steps:
  1. Create an ESRI Map via ArcMap
  2. Publish to ArcGIS Server via ArcCatalog
  3. Define a New Map Service in SAS Management Console
  4. Set a cube dimension as 'GEO' and link the source data for the cube to the source data for the ESRI Map
  5. View the Map via Web Report Studio or Web OLAP Viewer Reports
Tip:
Ensure that each level in the ArcMap includes a data element that matches up to a column in the cube's source data. Developing these two sources requires planning as these joins are critical in getting the map to display correctly.

Software Requirements:
  • ArcGIS Server
  • SAS Business Intelligence Suite with OLAP
References: