Sunday, August 06, 2006

SAS EG and .NET 2.0

Ok, so the official word is no .NET 2.0 apps in EG. I understand this position 100% and I agree with the position. Regardless, .NET 2.0 costs me 25-50% less effort than 1.1 so my goal was to see if I could hack out something that would allow me to post a 2.0 app in EG 4.1.

It is a hack, it's not official, it's limited, etc. but I successfully got my 2.0 app to run under EG and had it post my code to an EG task. Here's how I did it but it is simplistic and not pretty. I share it in case you need something similar.

First, create a 2.0 app. Make it a WinForm and have fun on layout, generics, etc.

Then change parts of your program.cs to something like the following:

MainForm frm = new MainForm();
Application.Run(frm);
Console.WriteLine(frm.SasCode);

All Winform apps can write to a console but this output goes to a standard out.

Then change your EG add-in to support it:

public SAS.Shared.AddIns.ShowResult Show(System.Windows.Forms.IWin32Window Owner)
{
Process proc ;
proc = new Process() ;
proc.StartInfo.UseShellExecute = false ;
proc.StartInfo.RedirectStandardOutput = true ;
proc.StartInfo.RedirectStandardError = true ;
proc.StartInfo.CreateNoWindow = true ;
proc.StartInfo.FileName = "AnalystToolkit.exe";
proc.Start() ;
proc.WaitForExit() ;
sasCode = proc.StandardOutput.ReadToEnd() ;
return SAS.Shared.AddIns.ShowResult.RunLater;
}

I could have done a lot more with standard out (and I probably will) but this shows you a quick and easy way to hack up a solution that works. From this standard out, you should be able to make out a way to do anything you need.


From out in left field and having fun,

Alan

2 comments:

Anonymous said...

I am looking for Senior SAS Analyst in Chicago, IL. We are a Healthcare Consulting Firm. Can I post jobs anywhere on this site? Do you have any ideas about other sites that I should use to advertise for jobs?
Thanks Maradee
email is mbarr@valencehealth.com

Unknown said...

The very heart of your writing shilst sounding agreeable at first, did not settle very well with me personally after some time. Someplace within the paragraphs you were able to make me a believer but just for a while. I nevertheless have a problem with your leaps in assumptions and one would do well to fill in those breaks. In the event you actually can accomplish that, I will definitely end up being fascinated.
Its such as you learn my thoughts! You seem to grasp so much approximately this, such as you wrote the ebook in it or something. I think that you simply can do with some% to force the massage house a bit, however other than that this is magnificent blog. An excellent read. I will certainly be back.

changeparts

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:...