I have doubts

One of my new work friends says this frequently. But the statement is lost in his translation from Portuguese, it is not that he does not believe me, it is just that he has questions about how things happen so he can learn. I debate on which version of this statement I get from others, especially when it comes to the "magic" of using a SAS Stored Process within a SAS Information Map. In summary, I get two main questions from the tip/example I posted back in '09 about using Stored Processes to use SQL Pass-thru from Information Maps:

  1. The first concern is with concurrancy
    What happens when multiple people hit the SAS Information Map at the same time? In the example, the most important statement is:
    libname BIOUT (work);
    This reassigns the library BIOUT to the location of work. If you are not familiar with SAS, this is the individual location for each instance of SAS that is distinct, temporary, and is completely removed if the SAS session ends normally. Therefore, reassigning your BIOUT location to (work) ensures that the table created dynamically by the SAS Stored Process is the file only for your run.
  2. Next is the question that no physical file exists
    Again with the use of libname BIOUT (work); everything is cleared when the session closes. So a physical file exists, but only briefly.

Now that you have no doubts about using this technique, how do you plan to leverage the power of SAS Stored Processes? If you need help getting started, I previously posted four ideas on how SAS Information Maps can leverage Stored Processes "Using Stored Processes to Improve Information Maps".

Post a Comment

Code wizards make the magic happen

Wizard Harry Potter makes magic just waving his wand around and shouting out spells. Using SAS Enterprise Guide (and you are welcome to shout out your own commands too) you can create some magic, allowing the Stored Process Wizard to code for you. On Step 2, the "Include code for" button allows you to choose whether the spell will include stored process macros, global macro variables, and references to libnames. In doing so, the key is to remember in magic and wizardry there can be a man behind the curtain. You will not see this when editing the stored process from Enterprise Guide, but the actual .sas file on the server contains all of this code.

In the below screenshot is the original code (squared off in red) with the three default additions created by the SAS Enterprise Guide Stored Process Wizard.

  1. *ProcessBody
    This was a required element for the SAS Workspace Server in 9.2 and prior versions. This alerted the server on where the code began.
  2. %STPBEGIN and %STPEND Statements
    Provides all of the header/footer information to enable output to ODS locations so that you don't have to code it yourself. There are instances where I recommend (and you are required to) not select this option, such as when generating custom HTML layouts.
  3. ExtendValidMemName
    Enables the use of an extended validmemname for 9.3+ versions. This will appear for all stored processes created from SAS Enterprise Guide 5.1, no matter what is selected in the "Include code for" button.


When I attempt to edit the code using the Stored Process Manager from SAS Enterprise Guide, I only see the two lines of code. In the majority of cases, this will work out just fine. But if you are trying to code something custom, just stay aware of what magic is happening around you!

Post a Comment

And the difference between Business Intelligence and Business Analytics is ...

After some discussion with SAS Product Marketing yesterday, we devised this response to everyone's question about the Business Analytic differentiator that SAS provides.

*********************************************************************************************************
Business Intelligence is one of the key components from SAS that ties into a suite of analytic techniques, information handling and performance infrastructures needed to deliver the insights through relevant Business Intelligence offerings. The majority of Business Intelligence systems provide general reporting capabilities (dashboards, web reports, etc.) to a wider group of users.

Business Analytical systems provide everything BI can do plus an additional level of functionality – the statistical analysis tools to complete tasks such as forecasting, regression, and modeling. Business Analytics from SAS includes ALL the key areas needed to successfully implement data driven decision making: Information Management, Analytics, Business Intelligence and tailored business solutions. The Business Analytics Framework is empowered by the High Performance Analytics capabilities from SAS.

*********************************************************************************************************

'Intelligence' and 'Analytics' can appear as very similar terms but in my mind (and in my thesaurus) they are not. The term 'Intelligence' is another word for Information, News, Communication. Therefore the tools included within a Business Intelligence system would be to provide that information or news to effectively communicate to a large audience. Whereas 'Analysis', synonymous with examination, evaluation, investigation, and scrutiny, is the actual task of slicing and dicing data, understanding past-present-future by exploring everything available. SAS Business Analytics includes High Performance Analytics capabilities. When given to business analysts, they can perform all the investigation and scrutiny their hearts can handle!

What do you think?

Post a Comment

Any SAS program can become a SAS Stored Process

Questions (or search strings) lead people to my blog or my email box on a daily basis and many of these are related to what SAS Stored Processes can or cannot do.

  • Can a SAS Stored Process query an RDBMS?
  • Can a SAS Stored Process create a data table?
  • Could it create an OLAP cube?
  • Can a SAS Stored Process create a PDF file (tip: use _ODSDEST), how about an Excel file?

Thankfully all I have to say is 'YES!', if a SAS program can do it then so can a SAS Stored Process (and with little to no tweaking). That is what makes SAS Stored Processes so incredibly awesome, the SAS developer can switch roles - from a bottleneck 'Run this job for me now' person to an enabler, creating reusable content that anyone can use immediately and with a couple minutes of click-this training.

Just remember, because all .sas files COULD become SAS Stored Processes doesn't mean that they all SHOULD become SAS Stored Processes. For example, .sas files that need to be run automatically and/or require no user interactions are not necessarily candidates for a SAS Stored Process. But .sas programs that require some modification to run for a specific need and/or are run when requested are absolutely good candidates. Can you think of other .sas programs that should (or should not) be considered for the SAS Stored Process job?

For more examples of what SAS Stored Process programs look like and can do, check out The 50 Keys to Learning SAS Stored Processes book. There are 35 SAS Stored Process examples covered and key after key of developing them.

Post a Comment

Where is the SAS code for that stored process?

Stored process code can exist within the metadata itself for version 9.3 (the benefits of which I discussed earlier). But for all other versions (and as a option in version 9.3) the SAS code is  stored as a .sas file within the server's file system (or mapped folder/drive structure). When editing stored process code directly, you need to know where the stored process .sas file resides.

Here are a few places to find that .sas file location. Do you have any other ways?
1. Through the SAS Management Console properties screen, select the Execution tab.

2. Using PROC STP (SAS 9.3)

 options metaserver = 'machine'
 metaport = 8561
 metauser = 'XXXXXXXXXX'
 metapass = XXXXXXXXXX;
 PROC STP PROGRAM='/Projects/Book Examples/12_d_AMOParetoEdits';
 list group=execution;
 run;

The output then provides:
-------------------------
NOTE: PROC_STP: ====== Stored Process: /Projects/Book Examples/12_d_AMOParetoEdits ======
NOTE: PROC_STP: ====== Metadata Listing for /Projects/Book Examples/12_d_AMOParetoEdits ======
NOTE: Logical Server: SASApp - Logical Stored Process Server
NOTE: Source Code Repository: C:\SAS\Stp Book
NOTE: Source File: Example_12d_AddInParetoEdits.sas
NOTE: Result Type: Packages No
NOTE: Streaming Yes
NOTE: PROC_STP: ====== End Metadata Listing for /Projects/Book Examples/12_d_AMOParetoEdits ======
NOTE: PROC_STP: ====== Stored Process: /Projects/Book Examples/12_d_AMOParetoEdits Return Status
= 0 ======
NOTE: PROCEDURE STP used (Total process time):
real time 0.63 seconds
cpu time 0.04 seconds

3. By running a metadata call
In the following example, I have a sas program that will pull out a full list of all the stored processes registered in the metadata, each corresponding .sas file and where in the server these physical files reside.

/*insert an options statement here to connect to your metadata server/port.*/
data new(keep=dirname stpname stpcode);
label dirname="Directory Name";
label stpname="Stored Process Name";
label stpcode=".sas File Name";
 length uri name dirname stpuri stpcode stpassn stpname $256;
  uri="";
  name="";
  dirname="";
  stpuri="";
  stpcode="";
  stpassn="";
  stpname="";

n=1; nobj=1;
    do while(nobj >= 0); 
        nobj=metadata_getnobj("omsobj:Directory?@Id contains '.'",n,uri);
    put nobj;
        if (nobj < 0) then leave; 
        rc=metadata_getattr(uri,"Name",Name); 
    rc=metadata_getattr(uri,"DirectoryName",DirName);
    if Name = "SP Source Directory" then do;
       rc1=1; x=1; 
        do while(rc1>0);
      rc1=metadata_getnasn(uri, "Files", x, stpuri); 
      rc2=metadata_getattr(stpuri, "FileName", stpcode); 
      rc3=metadata_getnasn(stpuri, "AssociatedTransformation", 1, stpassn);
      rc4=metadata_getattr(stpassn, "Name", stpname); 
      x+1;
       output;
      end;
    end;
        n+1; 
    end; 
run;
title 'All Stored Process Locations';
proc print label noobs;
run;

Included below is a screenshot of the resulting report.

Post a Comment

Selecting multiple individual dates in prompted reports

The date prompt from SAS Prompt Framework provides the options of single selection or a range, however what if you need to select multiple individual dates such as Monday (May 28), Wednesday (May 30), and Friday (June 1) of last week? There are a few alternatives to accomplishing this.

Option 1. Use a Text Prompt Instead of a Date Prompt

Set up a text prompt to select one or more values from a data source. The data source for the prompt would then be the date values represented within your data source - BUT FORMATTED AS CHARACTER. Of course, if this is a really large data source it would be better to use a permanent data table that is updated during your ETL processes with the sorted list of distinct dates.

Included is an example from SAS Information Map Studio.

1. Create a custom data element that reformats date into text. Use the custom expression to leverage the PUT statement as seen below.

In this example, the code is:          

put(<<PRDSAL3.DATE>>, mmddyy9.)

2. Use this new data element to create a prompted filter. As seen below, I have selected the dynamic list option (#1) and allowed users to select multiple values (#2). Then I used the custom data element DateText (#3) to populate the list itself.

When I test the information map prompt, I am now allowed to select multiple individual dates.

Option 2. Leverage a date dimension from an OLAP Cube

Rather than having the data source as a flat table, place it within an OLAP cube with the date as a dimension. Then the prompt will allow you to select one or more individual date values (if you select "Multiple values" for the Number of values drop down box as seen below).

Included is a screenshot of the resulting dimension filter from a test in SAS Information Map Studio.

Do you have any other tricks to getting prompts to operate as required but not readily available 'out-of-the-box'? Please comment & share!

Also, the prompting framework is an entire chapter in the book Building Business Intelligence Using SAS: Content Development Examples. If you buy the e-book to you can learn more about this cool functionality today!

Post a Comment

Change your passwords without locking out your connection

Did you change your LinkedIn password yesterday? (If you didn’t, you should!) But did it happen to be the same as your corporate password? First, tisk tisk. Second, change your corporate password NOW!

Ok, now that this is done ~ don’t let your saved connection profile for SAS applications lock your corporate account out later today. (The SAS connection profile is used in thick client applications including SAS Information Map Studio, SAS OLAP Cube Studio and SAS Management Console.) Before clicking the OK button to start a SAS connection, select Edit... and enter your new corporate password.

Select Edit Button on Connection Profile Screen

Next through the connection wizard until you see the password box.

Now SAS Administrators are probably going to be interested in ensuring that passwords are never saved in this system (especially after the LinkedIn fiasco). If this functionality was not disabled during the initial SAS configuration, administrators can go back and make that modification. Modify the XML property SASSEC_LOCAL_PW_SAVE from "T" to "1" to SASSEC_LOCAL_PW_SAVE "F" or "0" within the omaconfig.xml file located in the SAS Metadata Server configuration (Lev1/SASMeta/MetadataServer) and then restart the SAS services. Now the button 'Save user ID and password in this profile' (as seen in the 2nd screenshot above) will not be available for your SAS users and they will be forced to enter their password each time they initiate a connection.

Post a Comment

Backup or copy all components of your stored process before making changes

What if you would like to make a copy of an existing stored process to test out your changes before making them live? The copy command is available from within  SAS Management Console or from the SAS Enterprise Guide Open Stored Process GUI as seen below (note you can only paste the object in a different folder). The server designation, the prompts, etc are copied. And this is great if you would like to change and test only a metadata modification (such as switching from 'Stored Process' to 'Workspace' servers) or adding descriptions to prompts. But what about the underlying .sas code if you want to edit the stored process itself?

Open Stored Process GUI with Copy Selection

Right click on the Stored Process and Select Copy

(Need help with editing? Check out my co-author Tricia Aanderud's post about how to edit a stored process? )

Remember that in the majority of stored process implementations, there are two components to every stored process:

  1. the metadata registration
  2. the .sas code that runs on submission

(New in 9.3, you have the option to place sas code in the metadata registration itself, see my post about when this would be super useful.)

Anyhow, the copied metadata registration points to the original .sas code not a new .sas file. Modifying the stored process from Enterprise Guide immediately will cause you to edit BOTH the original stored process code and the new copy. (If you move to the Summary tab of a Stored Processes Properties, you can confirm that the source code path is identical to the original stored process.) You must make a copy of the .sas file in a subsequent step and edit the copied metadata to point to this second location before beginning any edits through the SAS Code window.

Included are the steps to do this full copy:

  1. Copy the stored process metadata registration and paste it in a separate folder
  2. Edit the stored process metadata registration to point to .sas copy

    Modify the .sas file name to a new backup file

    Move to the Execution Options area of the Stored Process Properties to change the .sas file name.

  3. Copy the .sas file on the server itself, rename to match #2.
    Sample from Windows on Copying File and Renaming to Match Properties Screen

    Ensure that this name exactly matches the properties screen.

    This is a great tip to remember. Maybe Tricia & I should consider it in a second edition of the SAS Stored Process book. Just goes to show you how difficult it was to come up with only 50 Keys to Learning SAS Stored Processes.

Post a Comment