Tuesday, November 18, 2008

SAS and Microsoft: Different Worlds

Well, first of all, sorry I haven't written recently. My time has been taken up by some great SAS work but it is under wraps for the time being.

I was chatting with a SAS buddy of mine recently and I started to comment on the differences between the SAS and Microsoft development communities. I like them both but they each have the pros and cons.

The Microsoft community travels fast, I mean lightening fast. There are constant updates, massive 3rd party support, great forums, blogs, etc. from the Microsoft developers to always keep people updated. Best of all, the constant changes means that it is always exciting and new. Like getting several Christmas's a year. Cool new technologies like Silverlight (WOW!!), C# 4.0, Office 2007, Windows 7, LINQ, etc. On the 3rd party front, I have dozens of graphing toolsets I can use. Dozens of databases, etc.

That is also their con which is that you always have to be learning and never catch up. It also leads to a lot more uncertainty with how things work which can be a detriment when building enterprise systems.

The SAS community is much slower to change. Part of this is due to the Institute which doesn't release software very often and keeps the software fairly static.
I like that I can count on Base SAS to work each and every time. It is still the best way of manipulating data that I know of. Also, the user community (SAS-L, mainly) is a club with the same players each year. I like the steadiness of the SAS community and the software. When I go to a SAS conference, I know people. The Microsoft conferences tend to be a madhouse and you have to arrange to meet people you might know.

The con with SAS is that steadiness. The lack of change means that people still use older technologies such as DDE and do not explore further. So often, I see the same way of doing things being recommended rather than people stepping back and asking if there is a better way. The insularity of the community tends to hold back innovation, IMO. SAS does not have a 3rd party ecosystem so you don't have other companies being encouraged to develop new ways of using SAS.

At the end of the day, though, I like SAS and Microsoft. Each has strengths and weaknesses.

Lastly, I would encourage SAS developers to find dual interests simply to see alternate ways of doing things. Not everyone needs to embrace Microsoft but I see a great positive in adopting multiple technologies simply to change the view of the world.

Tuesday, August 12, 2008

SAS Integration Technologies and Vista

Ok, I am sure that I will get some grief about this but I needed to submit my SAS code from a .NET application. this was on my new PC which is running Vista 32. Anyway, no matter what I did, I kept getting the following error:

"Retrieving the COM class factory for component with CLSID {440196D4-90F0-11D0-9F41-00A024BB830C} failed due to the following error: 80040154."

Well, normally that is addressed by simply installing the IntTech client and setting permissions to None in dcomcnfg. It didn't work this time.

Here is what i did to fix it (people can try these in isolation to see which one is the root):

1. Right-click on the the inttech.exe file and run it in compatibility mode for Win XP SP2

2. Go into dcomcnfg and set every single SAS DCOM object with permissions of None.

I could play with this some more but I am now behind.

Update 3/31/2010

This worked for me on Windows 7 64 and when the dcom stuff failed:

To register the IOM server,

1) Copy SASVRSRV.DLL from !SASROOT\CORE\SASEXE which can be found on
the SAS System CD or a Network copy of SAS to your Client
!SASROOT\CORE\SASEXE directory.

2) From a command prompt run !SASROOT\SAS.EXE /REGSERVER

Tuesday, May 06, 2008

Microsoft Project Files, SAS, and .NET

Ok, another fun, fun time with SAS and an obscure area. Here's the scenario, the client needs data from an MPP file (Microsoft Project) converted into a SAS dataset. I tried lots of routes, all to no avail. As usual, I get to go through the mess of COM interop, lack of documentation on the web, and SAS not supporting write access in the local data provider. Ahhhh, the joys of consulting ;-]


I finally got the following C# code operational and it writes the data into a SAS-friendly XML format. I hope this helps someone else:

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.MSProject;
using System.Reflection;
using Savian.Core;
using Savian.DataManagement.Delimited;

namespace Client.ReadProjectFile
{
public class Main
{
List tasks = new List();

public void Process(string file)
{
ReadMppFile(file);
ConvertFileToSas();
Console.ReadLine();
}

private void ConvertFileToSas()
{
DateTime start = DateTime.Now;
Console.WriteLine("Start converting to SAS..." + start.ToShortTimeString());
DataTable dt = tasks.ToDataTable("TABLE");
dt.WriteXml(@"c:\temp\Client.xml");
DateTime end = DateTime.Now;
Console.WriteLine("Finished conversion..." + end.ToShortTimeString());
Console.WriteLine("Elapsed time: " + (end - start).TotalSeconds + " seconds");
}

private void ReadMppFile(string file)
{
ApplicationClass app = new ApplicationClass();
app.DisplayAlerts = false;
app.ScreenUpdating = false;
app.Visible = false;
app.MacroVirusProtection = false;
app.FileOpen(file, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, PjPoolOpen.pjDoNotOpenPool,
Missing.Value, Missing.Value, Missing.Value, Missing.Value);
var mppTasks = app.ActiveProject.Tasks;
int i = 0;
DateTime start = DateTime.Now;
Console.WriteLine("Start creating records..." + start.ToShortTimeString());
foreach (Task task in mppTasks)
{
ProjectInfo pi = GetProjectInfo(task);
tasks.Add(pi);
i++;
if (i % 100 == 0)
{
Console.Write("Records created: " + i);
Console.SetCursorPosition(0, 1);
}
}
Console.WriteLine("Records created: " + i);
DateTime end = DateTime.Now;
Console.WriteLine("Record read completed..." + end.ToShortTimeString());
Console.WriteLine("Elapsed time: " + (end-start).TotalSeconds + " seconds");
app.FileClose(PjSaveType.pjDoNotSave, Missing.Value);
}

private static ProjectInfo GetProjectInfo(Task task)
{
ProjectInfo pi = new ProjectInfo();
AssignFields(ref pi, task);
return pi;
}

private static void AssignFields(ref ProjectInfo pi, Task t)
{
pi.Name = t.Name;
pi.Start = (DateTime)t.Start;
pi.Finish = (DateTime)t.Finish;
pi.Id = t.ID;
pi.PercentComplete = Extensions.GetIntValue(t.PercentComplete);
pi.Duration = Extensions.GetIntValue(t.Duration);

}
}
}

class ProjectInfo
{
public int Id { get; set; }
public string Name { get; set; }
public DateTime Start { get; set; }
public DateTime Finish { get; set; }
public int? PercentComplete { get; set; }
public int? Duration { get; set; }
}

Sunday, March 23, 2008

Silverlight Lessons Learned

After a shotgun week of Silverlight 2.0, I thought I would share a few lessons learned.

Blank page

If you get a blank page after uploading your xap file, make sure that NETWORK SERVICE is in the security accounts.

XAP File

XAP is the only file that needs to be moved typically. As you do your code updates, just move the XAP file into place.

Dynamic XAML

Dynamic XAML requires a namespace attribute now:

<Grid xmlns="http://schemas.microsoft.com/client/2007">

Timing Issues

There seems to be a timing issue in Silverlight that is causing an event to get triggered before the data streams down from a site. This still requires investigation.

Visual Studio 2008 and Silverlight Debugging

For some reason, if a serious Silverlight error occurs, debugging will be disabled in the web application. This may make it seem like events are not firing when they are, just that the debugger is broken. Right-click properties on the web application --> Start Options --> Debuggers --> Check Silverlight

Overall

Overall, I love XAML and Silverlight. It was absolutely incredible to work with but it took a lot of time due to minimla information on the web right now. Hopefully, this post will help some other folks out.

Friday, March 07, 2008

Microsoft Silverlight

I have been in Vegas all week at the Microsoft MIX08 conference for the rollout of Silverlight 2.0. It is so revolutionary that it really got me thinking. That and SAS Global Forum made me mull a few thoughts:

1. Silverlight is going to revolutionize the world. Bold statement, I know.However, what I saw, as a web developer, absolutely stunned me. If you don't believe me, see what NBC will do with the Olympics. 2200 hours of hi-def video, 4 channels per user, VOD, and just much, much more.

However, check this out for something live now:

http://memorabilia.hardrock.com/

Data visualization and BI will move toward Silverlight. SAS should move there as well. as quickly as possible. SAS should be a leader here and not follow the inevitable.

2. Microsoft is innovating at an amazing pace. Windows Server 2008, Silverlight, Surface, Vista, IE8, IIS7, and on and on. Meanwhile we await a .07 release from SAS that is languishing once again. Basic project management: reduce scope, increase budget, adjust timeframes...hmmm, it seems like the only option at SAS is the latter and I honestly don't understand it. Hopefully, SAS Global Forum will provide some answers.

3. Silverlight controls are being released open source. Office formats are now open, the .NET source code has been released open source. I think SAS can learn from this and realize that money can be made without keeping everything tight to the vest.

4. Integration Technologies should be bundled with Base. All of this new technology requires it so why, as a customer, do I have to have a separate line item? Put SAS/IntrNet in that category as well. Why does web enablement cost extra from SAS. Pay more and realize it is 2008 and web enablement is part of Base SAS.

5. Microsoft actively encourages blogging even if it is critical of the company. People should be trusted and I have found most use discretion, especially if they are employees. Blogging and active user participation helps sell the company message and actively engages the user community. A once a year conference is not enough in today's fast-paced world. SAS Forums are fine, SAS-L operates via 'birdies' but wouldn't it be great to have blogs from Paul, Vince, Chris, Eric, etc. out in the wild? Open and free, give and take, user comments...

As a SAS advocate, user, former employee, and partner, I am asking for change. More openness, more releases, more interaction. Simple stuff that is doable today.

Wednesday, February 06, 2008

SAS LanguageService and You

For those of us who work with SAS LanguageService on a regular basis, it is frustrating. The entire SAS COM interface is very poorly documented and is light on functionality. It gets better over time but it would be much nicer to have a .NET interface so we don't have 50 COM nulls in a single method call.

Ok, that all said, I just came off of a marathon (10+ hours) bug fix that damn near drove me mad.

I was submitting a simple query via the Language Service:

proc sql;
create outdata.test as
select *
from DICTIONARY.COLUMNS
where …some criteria…
;
quit;


Ok, no problem. I could submt the query within the SAS Editor and it would work fine. However, DEPENDING ON WHERE I WAS IN MY .NET CODE, it would return 0 rows. Huh!?!? It wasn't the dataset, it wasn't the syntax for the call, it was where the call occured at during processing. Holy smokes Batman! That's a bear of a bug to catch.

You do the normal stuff and isolate, isolate, isolate. Well, it took a long time to isolate that it was where it was being called. Damn, damn, damn...one of the toughest bugs I have hit in years.

My answer for how to solve it:

Common.SAS.LanguageService.Reset();

(I am using a static class called Common).

Will this answer stand the test of time? Not sure. I have asked my buddy at SAS whether I am on the right track.

Back to the first point: better documentation would be welcome. Even better, an ADO.NET data provider WITHIN Base SAS. Don't make me buy IOM to use SQL processing.

Ah well, back out to the far corners of the ballpark I go...

SAS throwing RPC error

If you are doing code in C#  and get this error when creating a LanguageService: The RPC server is unavailable. (Exception from HRESULT:...