Showing posts from 2012

SAS XPT Files, IBM Floats, and C#

Well, I recently was asked if I could support XPT files, you know, the SAS transport format. Well, SAS transport formats are documented and fairly straight-forward to read so 'why not?'.

Got started coding, client provided a nice sample, all went well. Around 8-10 hours after starting, I was happily reading SAS transport files and writing them to a tab-delimited file.

However, things weren't happy on Big Rock Candy Mountain.Seems the numbers were off. A little bit of reading in the SAS XPORT Documentation indicated the problem:

"All floating-point numbers in the file are stored using the IBM mainframe representation. If
your application is to read from or write to transport files, it will be necessary to
convert native floating-point numbers to or from the transport representation."

Not a problem. Let's go track down a C# library that handles IBM 370 floats and does the conversion. One small problem...I couldn't find one. What I did find was that this was…

DNN Error

I have been using DotNetNuke (DNN) A LOT recently. For building a web framework, it absolutely rocks and is very easy to use. It is also very popular (I think 800k sites and growing) so there are loads of add-ons, videos, help guides, etc. Plus, it is free. I may need to put my demos site under it and showcase SAS a bit.

Normally, it is also pretty easy to use. Recently, though, I encountered a tough issue to debug.

I encountered the following error on opening the site:

An error has occurred. An error has occurred.

As I read up on it and understood it a bit more, lots of things can cause it. Basically, DNN has a serious error and it will not start.

To help diagnose it:

Go to the SQL Server database and open up the EventLog. Go to the last events in the log. An error on compilation or missing files typically will generate multiple entries. Look for the cluster of errors at the bottom of the log.For the first record of the error, select the LogProperties, right-click and copy. Save this to a…

SAS & Excel Via Local Provider

A question came up on SAS-L for how to get Excel to read SAS datasets using the Data Sources within Excel. Here are some screenshots showing how it works:

Hash a SAS Value

Sometimes, it is good to be able to hash a value so that a unique key can be made into the data. For example, say you were looking at a system performance log. You have a PID, a process name, and a user. PIDs are reused by a system all of the time so trying to narrow down uniqueness throughout a day is hard.

It order to get a unique value, you could concatenate the values into one:

000789654 || WeeklyProcess || gertre5

We are assuming that there is no need to ever reverse the values. This is a key assumption.

There is an undocumented function in SAS called CRCXX1 that can create a unqiue hash. Here is some code illustrating it:

data A; input name :$200. gender :$8. state :$20.; x = compress(name||gender||state); y = CRCXX1(x); put x= y=32. ; datalines; Churchill,Alan Male Colorado Churchill,John Male Colorado ; run;
The results:

data A; 884 data A; 885 input name :$200. gender :$8. state :$20.; 886 x = compress(name||gender||state); 887 y = CRCXX1(x); 888 put x= y=32. ; 889 datal…


I was just tasked to read in LDAP records so we could cross-reference userids with login identifiers and general ledger information.

Using SAS to read LDAP was a bit of a challenge. I had used C# to read LDAP before and had been successful at several engagements. However, I had never journeyed into SAS land on the LDAP front. The information on how to do it is sparse. More than that, LDAP is very, very sensitive to wrong information and the response when rnning the code is simply 'LDAP Failed'.

LDAP provides a tremendous datasource for SAS developers.

Let me show you how to work with it:

1. Download and install LDAP browser by Softerra. It is crucial to help navigate the LDAP waters.
2. Pick a simple LDAP server to start with. I will use Colorado State University. Lots of colleges have public LDAPs so they are perfect. For our example, we are going to find details on the faculty of the history dept (my undergrad was history).

Here are the specifics:

LDAP server:directory.colos…

SAS/IntrNet and IIS 7.5

First of all, I had to set up SAS/IntrNet recently. I do this at times and always struggle with security
issues in IIS. Hence, I document it below.

People may ask why use SAS/IntrNet anymore? Well, it is fast and is probably the fastest way to interact with SAS via the web. It has limitations but it implements a standard REST api that is used by loads of web companies (i.e. Twitter, Facebook, etc.). I absolutely love IntrNet due to its simplicity.

Let's make it happen:

I posted a short while back on how to get SAS/IntrNet operational on IIS 7. Well, I had to do everything again under IIS 7.5 and eiteher things have changed slightly or I didn't get it all captured last time. So here we go again, but this time with pictures:

1. Open up IIS in Windows Server 2008 R2 and right-click on sites, Add a new site:

2. Fill in the details:

3. Pay attention to the application pool and any host header information. Host headers are nice for h…