To be or not to be, testing your cube's existence

Unlike BASE SAS tables, OLAP cubes must exist in within the metadata in order to access from any of the OLAP Viewers. In addition to having some metadata OLAP cubes have a physical file structure presence (at least for MOLAP/HOLAP because it's a different story for ROLAP). When you refresh these cubes, the physical file structure is scrapped and recreated. If something goes horrible wrong, the metadata remains but the files are simply ... gone.

From SAS OLAP Cube Studio, the icon next to the cube name changes slightly. This represents the fact that the cube exist in name alone.

But what can you do to check whether it was successful during batch processing? Fortunately, SAS users are sharers. A quick Google search on my custom Google search engine resulted in this SAS Community post on checking to see if a directory exists. You can use this outright, or if you don't have the path handy you can search through the metadata using data step functions and run the whole thing with only the cube name as input.

/*Specify the cube name*/
%let cubename = SalesSummary;
/*Use the Data Step Interface to Metadata*/
data _null_;
  length path cubeuri diruri $256;
  path="";
  cubeuri="";
  diruri="";
/*    Find the CubeURI*/
  rc2=metadata_getnasn("omsobj:Cube?@Name='&cubename'","AssociatedFile",1,cubeuri);
/*    Find the Directory URI*/
  rc3=metadata_getnasn(cubeuri,"Directories",1,diruri);
/*    Retrieve the DirectoryName Value*/
  rc4=metadata_getattr(diruri,"DirectoryName",path);
  call symput('path', strip(path)); 
run; 
 
/*Set the SASCommunity.org Macro*/
%macro DirExist(dir) ; 
   %LOCAL rc fileref return; 
   %let rc = %sysfunc(filename(fileref,&dir)) ; 
   %if %sysfunc(fexist(&fileref))  %then %let return=1;    
   %else %let return=0;
   &return
%mend DirExist;
 
/*Determine if the physical path exists*/
%put %DirExist(&path\&cubename\gen0000);

If it returns a 0, you know that the refresh code failed and there is no data there. You could use this to send an alert or to move to a different phase of the process. What would you do with this code? What other uses can you think of?

Post a Comment

Skipping through OLAP to find your value

One of the cool things with SAS OLAP Viewer in Add-in to Microsoft Office is your ability to skip right into a specific value. Out of the box, viewing OLAP cubes can lead you to believe that in order to view a specific value you need to click-thru a hierarchy & choose Isolate from the menu to only view that single value. But what do you do if the value is hard to locate in the dimension? What if you want to Isolate more than one value in the report?

Fortunately, the Edit View interface provides search functionality which allows you to choose one or multiple results to quickly get the report you so desire.

Don't believe me? Well, here are the steps.

  1. Open an OLAP Cube in SAS OLAP Viewer
  2. Right click and choose Edit View -> Edit with View Editor
  3. Choose the Search tab
  4. Modify the search criteria (options include contain, start with, end with, match pattern, blank, etc)
  5. Type in a value to search (such as Chocolate, my favorite)
  6. Choose the Dimension to search within
  7. Click the Search button
  8. Highlight the value(s) which you would like to view
  9. Choose the arrow to move values into the Columns, Rows, or as a Slicer
  10. Select Ok

Now the resulting screen shows only the 4 chocolate candies I had chosen in the search.

And a quick tip about searching - it's not an automatic filter. In my example, if I already had all of the products listed in the report than my search would either not work (saying it was already in the view) or it would duplicate the result (depending on what level in the hierarchy the value I selected in step 8 above). Therefore, before you begin using the Edit View Search GUI I would recommend setting the current view at the top level.

Note: I did all of this with SAS Add-in to MS Office 4.3, accessing a SAS 9.2 environment.

Post a Comment

Best practices for refreshing production OLAP cubes

Unlike prior versions of SAS OLAP technology, 9.2 provides more options for maintaining and refreshing OLAP cubes. With this comes some discussion about what each one does alone, and how pairing these techniques really provides SAS OLAP Server Administrators and cube developers a cornucopia of OLAP options.

PROC OLAPOPERATE

Remember using the option DELETE_PHYSICAL from the OLAP PROC in 9.1.3 and getting errors when users were still connected to the OLAP cube? In prior versions, you could restart the OLAP Server to manually kick the users out of the system. You can now use SAS Management Console to stop specific user sessions. But when refreshing OLAP cubes in batch, use the PROC OLAPOPERATE technique to DISABLE and ENABLE the cube programmatically.

Update In-Place

If you chose to use the OLAPOPERATE procedure described above, you could run into a situation where a report using the cube is run & fails because the cube is getting refreshed and is currently disabled. Using Update In-Place allows you to add more data to the cube anytime you like, users that are currently connected will not get kicked off and you won't receive any errors about locked cubes. However, using this option alone could mean that it takes awhile for the new data to be available to the users. That's because the new data isn't "pushed" into the cube until ALL sessions accessing this cube are disconnected.

In Section 5.7.4 of my book Building Business Intelligence Using SAS: Content Development Examples, I describe implementing both the Update In-Place technique and PROC OLAPOPERATE disable/enable options to quickly refresh the cube data and get it pushed to users programmatically.

Incremental Updates

Remember having to refresh the entire cube to add any new data? Or receiving user requests to validate the cube before updating all the reports? With incremental updates, this is done using multiple PROC OLAP and PROC OLAPOPERATE steps. The SAS OLAP Server documentation provides a sample step by step approach. But don't forget to occasionally Coalesce Incremental Data using PROC OLAP COALESCE_AGGREGATIONS option. This will keep your filesystem to a more reasonable size, as each incremental refresh generates a new folder of aggregation content.

Post a Comment

The best part of writing a book is learning something new

Many of the chapters in my new book Building Business Intelligence Using SAS: Content Development Examples were straightforward to write but one in particular was the beast. Neither Tricia nor I wanted to tackle the SAS BI Dashboard chapter. Just chalk it up to no major work experience with this product to draw from. After picking the short straw, I had the privilege of trying to figure it out. Well, this product has since turned into one of my favorite tools of the SAS Business Intelligence solution (and I think maybe Tricia's too).

  • Just a week or so after creating the initial draft, a customer called me to ask about the indicator titles. Did you know these are edited from the dashboard view rather than on the indicator itself? That's on page 305, in section 9.4.1 Font Styles and Sizes.
  • Then a couple days later (I'm not kidding), a co-worker asked how to get a custom graph into the dashboard because there wasn't an indicator to meet their client's need. Section 9.4.4 shows how to use a Stored Process as an indicator.
  • And the coolest thing that SAS BI Dashboard can do is generate (without any code) a fancy interface with prompts and output results on the same page. Something requested of SAS Stored Process developers often but html/javascript/etc code is required to fulfill the requirements. Refer to Sections 9.5.2 Cascading Prompts and 9.5.4 Brush Interactions between Indicators. Included is a screenshot of the sample we create in the chapter.


Building Business Intelligence Using SAS: Content Development Examples is now available for purchase. Tricia also created a Peek Inside on her blog if you are looking for information on what else is contained in the book.

Once it arrives, let Tricia & I know what chapter is your favorite!

Post a Comment

Complete your order using preview results in SAS Add-in to MS Office

Recently I've made several online purchases buying eBooks for the new Amazon Kindle my daughter received as a holiday gift. The online checkout process is very straight-forward, especially with the 'Continue' buttons that change to a 'Place your order' button on the final step.

Did you know that the same option is available from SAS Add-in to Microsoft Office? This gives you the ability to cancel your entire order (meaning SAS Task results) or choose to insert only a subset of the results generated. For statistical tasks which generate multiple outputs, this is a quick way to include just what you want in the document or spreadsheet.

Setting this option will cause all of your Add-in components to operate in this fashion. Here is the only step:
From the SAS Add-in To Microsoft Office Menu Bar, select Tools -> Options, move to the Results tab and then choose the Show Preview Changes dialog box.

Now every time you run a task a 'Place your order' button appears. Well not quite, the buttons actually read Insert All, Insert Selected Items, or Cancel. To Insert Selected Items first click one or more results (while holding the CTRL button).

Post a Comment

SAS BI Dashboard: It's all in a name

When developing content in SAS BI Dashboard, such as indicators, ranges, and dashboards, knowing how to name them is pretty important. If changes are required later (for instance to improve the administrators capability of partial promoting content) much more work is required to ensure the links between the objects isn't affected.

SAS recommends that you plan out a naming strategy. Included below is an example that groups all the objects within a dashboard with a number or name, contains type information (such as KPI, DATA, RANGE) and a descriptive bit of text. You can see the relationships between the groups and probably can correctly guess the data sources for each indicator.

  • Common_KPI_CountryPrompt
  • Common_KPI_ZipPrompt
  • 01_DATA_SalesResults
  • 01_DATA_Investments
  • 01_KPI_SalesResults
  • 01_KPI_InvestmentRep
  • 02_DATA_CallSummary
  • 02_KPI_IncomingCalls
  • 02_KPI_CallLength

This approach not only aids the administrators promotion process, it can help with training or handing off dashboard management and development to another resource. However executives using these dashboards will ask for something more. The great thing is that the indicators actually have two names, one stored in the metadata and one displayed to the user. For BASE SAS programmers, this is very similar to variables with actual names (remember the 8 character limit) and a defined label that displays a more concise name to the user.

My awesome Co-author Tricia Aanderud posted recently about creating a BI Dashboard to kick Google Analytics results up a notch. Look closely at her spark table indicator, it was initially named 'ind_sparkline' but the final screenshot shows that the title 'Monthly Traffic by Week'. Think the second one is much more useful for the audience don't you? Within my prior post Changing or Removing Name I describe how to edit the displayed name or remove it altogether.

Another trick is to edit the format of these displayed names. Here is the post describing how to do this: Edit & Formatting of Name. Tricia and I will be sharing these tips and others during the SAS Global Forum conference in April. Hope you can join us!

Post a Comment

New job, same technology, huge customer value

As many of you have already noticed, my LinkedIn profile and the blog profile blurb have changed. I took on an exciting new job in the SAS Solutions OnDemand team. The official title is Software Development Manager, but what I really do is lead a team of fraud solution architects. Observant readers have already asked what this fraud stuff is about and more importantly (grin) if my career move changes my blog's SAS Business Intelligence focus.

Last week, within all of the Fortune Best Place to Work announcements there were specific references on SAS anti-fraud growth. SAS CEO Dr. Jim Goodnight mentioned to the NY Times that the increase in fraud is likely attributed to the recession. At the same time, the recession has also caused governments and industry to focus on fighting fraud as well as reducing the abuse and waste. Jim Davis stated that this was one of the biggest growth areas for SAS in 2011, with a 121% revenue increase. From our customer's standpoint, implementations of the SAS Fraud Framework have returned significant value on their investments.

Step 1. Integrating Data

One of the biggest strengths of SAS software is the ability to read data from a huge number of sources. A recent award for CJLEADS (another product created by SAS Solutions OnDemand) highlights this capability by combining county and state level data across multiple agencies into an enterprise criminal justice information system. To fight fraud, we have to employ the same data integration strengths because data is quite frequently disparate and disorganized. If we waited for a central data warehouse before running analytical models, it might be an additional year (or more) to demonstrate true value. My team of SAS developer rock stars pulls all of the available data from your organization together and prepares it for our in-house analysts.

Step 2. Applying Advanced Analytics

Statisticians in our Advanced Analytic Lab then crunch, slice, model (etc etc) the data to help your organization discover fraud previously hidden below the radar of your known business rules and anomaly detection checks. With the additional forecasting and social network analysis SAS provides the unique look into data relationships.

Step 3. Displaying Alerts and Capturing Findings

This is where my star team comes back into focus. We then create and implement resulting reports for display within the SAS Social Network Analysis web application browser. The technology behind most of this is SAS Stored Processes with additional reports available through the SAS Business Intelligence clients Web Report Studio and BI Dashboard.

So yes, I will continue to post SAS Business Intelligence topics here. Hopefully some of the topics will be even more interesting!

Post a Comment

Building custom measures for OLAP cubes

In one minute (and 10 seconds, but are you measuring that?) you can add a custom measure (also known as calculated members) to your OLAP cube. Watch this video to create a simple calculation multiplying units * price.

Remember that this mechanism is not just used for multiplications, you can choose to use MDX functions to generate complex logic.
One of my favorites is to use IIF techniques to test for conditions. An example is available in the SAS Global Forum paper "Measures, Members, and Sets, Oh My!" from my friends Bryan Stines and Ben Zenick. Another friend, Steve Overton, posted a blog post about using MDX to generatepercent of totals. For more information on MDX logic, the Microsoft programming technique for MultiDimensional Expressions is available at http://msdn.microsoft.com/en-us/library/ms145506.aspx.

Two very nice things about creating custom measures:

  • Anyone accessing this cube from Enterprise Guide, Information Maps, Web Reports, etc etc can use this custom measure - making it reusable!
  • These measures are calculated on the fly. Using this mechanism measures are not pre-calculated but are based on what the user has selected for view.

For those with no youtube access - here are the basic steps:

  1. Select the cube name on the left panel of OLAP Cube Studio
  2. Click the Calculated Member icon on the top menu bar
  3. Select Add to create a Calculated Member
  4. Follow the GUI to create simple or time based calculations
  5. For custom MDX expressions, choose custom calculations and then click Build Formula
Post a Comment

OLAP users can fall into the abyss of detail data

OLAP cube developers might have noticed that the amount of time required to generate any aggregation (including the NWAY) can negatively impact their productivity. Developers remove the NWAY aggregation (following the sample screens in a prior post) to significantly reduce build time and allow quick modifications to the cube definition.

Previously I explained what is an NWAY anyway. In one sentence, an NWAY is a summarization of the crossjoin between all levels defined for use in the OLAP cube. Removing this NWAY is typically not recommended for consumers of the OLAP cube. You might speed up development, but a user could drop off into the abyss of detail data & experience slow performance. Thankfully for this stick figure, the green box of NWAY is there to save the day.
Dropping into the abyss of Detail Data

So before these non-NWAY OLAP cubes are promoted into production take a moment to consider how the user could be impacted.

Post a Comment

Limit the number of drill-through to detail records available from OLAP cubes

Drill-through to detail is the ability to right click within a cell of a web report or OLAP viewer and request the detail source records that make up that specific cell's measure. The maximum number of records, by default, is set to 300,000. Feasibly the report user could download all of your source records (if the source is smaller than 300,000 records) from the top level of the OLAP cube. Of course we all know that allowing users to grab everything not only eats server resources it does not encourage using the OLAP cube for what it's real purpose is - adhoc slicing and dicing of the data.

Therefore, for many organizations, it might make sense to reduce the maximum number of records available to something much smaller. 1000 records, 5000 records, something agreeable ... but something that causes them to use the OLAP cube first to filter/analyze information and then drill through to the source records. Training is imperative when implementing this, since users will quickly get confused when the number of records in the OLAP cube does not match the number or resulting records expected in the drill-through data.

SAS Administrators can  implement this change, server-wide, in SAS Management Console. Navigate to the OLAP Server Advanced Options screen found in the properties.

Select the Server tab and modify the 'Maximum number of flattened rows' value from 300,000 to something smaller. In the example below, I've changed the value to 30.

The resulting data queries only provide 30 records of data to the users. In the example below, I have requested all of Bulls Eye Emporium data but only 30 records (on the right) appear.

Post a Comment