This blog is designed to show various ways to use Data Virtualization, technologies, and SAS with Microsoft technologies with an eye toward outside of the box thinking.
Thursday, March 02, 2006
Web Services
<webservices>
<protocols>
<add name="HttpPost">
<add name="HttpGet">
</protocols>
</webservices>
That should get you running.
Monday, February 27, 2006
RoboHelp and IIS 6.0
I hope this helps someone else in this same boat.
Alan
Thursday, February 09, 2006
Web Services and SAS
- An API has to be created and maintained over time
- Neither application plays to its strengths but instead each one 'dumbs' down to the lowest common denominator of both applications
- You always have to search for the specific API to use to get anything done
- There is no central way of managing these APIs and you get a lot of code bloat
To solve these issues, web services were born. Now web services may sound like voodoo or black magic but they are very, very simple. Everyone, and I mean everyone (including SAS), agreed to have a common means (XML) of transporting information between each other. I won't go into the ugly details of web services because the web is rife with them but let's talk about how they could be used to solve the typical SAS scenario I mentioned above.
You have SAS running on a Unix server and all of your users want it in Excel.
Old solution: Use SAS\Access to create an Excel file, use ODS to create a very bloated Excel file, write out to CSV, etc. Run the code, ftp the file to a server for delivery, have the end users read in the data and parse it themselves, or again use ODS and figure out the coding needed to create an Excel report.
New solution: Create a web service on Unix that reads in the SAS data using OleDB, ODBC, etc. and just expose a service (let's call it GetSasData("ExcelData"). Next have Excel consume that service and parse the data into the exact Excel report you need.
Ok. You may say that the new solution doesn't sound much better than the old. But wait!! Your boss now comes along and says can you please make that same data available to Lotus 1-2-3 and StarOffice. AHHHHH!!!! Under the old method you need to rewrite all of that ODS or just create an entirely new package. The boss then asks you to also support SAP and Oracle. AHHH!!
Ok, web services wouldn't require any changes because Oracle, SAP, etc. support web services. They can just consume that service the same as Excel. But, you claim, CSV is supported by everyone as well.
Actually, it isn't. Take the following CSV file:
Name Age Gender
Bill 29 M
Mary 32 F
Now is name a numeric, string, what does Name mean? CSV doesn't tell you and never will. Web services have support for typing information so you know what it is.
This blog merely scratches the surface. Don Henderson and I have put up some sample web services for people to play with over here:
http://demo.savian.net/SasWebServicesDemo/Service.asmx
I urge you to check them out and see what the possibilities are.
Out in left field and loving it,
Alan
Web Services and SAS
- An API has to be created and maintained over time
- Neither application plays to its strengths but instead each one 'dumbs' down to the lowest common denominator of both applications
- You always have to search for the specific API to use to get anything done
- There is no central way of managing these APIs and you get a lot of code bloat
To solve these issues, web services were born. Now web services may sound like voodoo or black magic but they are very, very simple. Everyone, and I mean everyone (including SAS), agreed to have a common means (XML) of transporting information between each other. I won't go into the ugly details of web services because the web is rife with them but let's talk about how they could be used to solve the typical SAS scenario I mentioned above.
You have SAS running on a Unix server and all of your users want it in Excel.
Old solution: Use SAS\Access to create an Excel file, use ODS to create a very bloated Excel file, write out to CSV, etc. Run the code, ftp the file to a server for delivery, have the end users read in the data and parse it themselves, or again use ODS and figure out the coding needed to create an Excel report.
New solution: Create a web service on Unix that reads in the SAS data using OleDB, ODBC, etc. and just expose a service (let's call it GetSasData("ExcelData"). Next have Excel consume that service and parse the data into the exact Excel report you need.
Ok. You may say that the new solution doesn't sound much better than the old. But wait!! Your boss now comes along and says can you please make that same data available to Lotus 1-2-3 and StarOffice. AHHHHH!!!! Under the old method you need to rewrite all of that ODS or just create an entirely new package. The boss then asks you to also support SAP and Oracle. AHHH!!
Ok, web services wouldn't require any changes because Oracle, SAP, etc. support web services. They can just consume that service the same as Excel. But, you claim, CSV is supported by everyone as well.
Actually, it isn't. Take the following CSV file:
Name Age Gender
Bill 29 M
Mary 32 F
Now is name a numeric, string, what does Name mean? CSV doesn't tell you and never will. Web services have support for typing information so you know what it is.
This blog merely scratches the surface. Don Henderson and I have put up some sample web services for people to play with over here:
http://demo.savian.net/SasWebServicesDemo/Service.asmx
I urge you to check them out and see what the possibilities are.
Out in left field and loving it,
Alan
Monday, January 23, 2006
Convert SAS datasets to Excel
These are the means (outside of SAS) that I am aware of using as well as pros and cons:
XML (for Office 2000 and better)
Pros
- Easily written
- Works pretty fast
- Excel not required on machine
Cons
- Creates enormous files. Have to open and then save as
old Excel using COM to reduce file size - Hard to work with the XML model due to its top to right
formatting. No real random cell access that I can find.
VSTO (Visual Studio Tools for Office)
Pros
- Built-in support in Visual Studio (ie easy editing)
- Microsoft 'direction'
- Does not require Excel
Cons
- COM based (slow, 1 instance only)
- Requires Visual Studio
- Requires coding in a different language
(VB.NET or C#) - Only supported on Windows
VBA in Excel
Pros
- Well-documented. Fairly easy to use.
Cons
- VBA will be deprecated, probably in Office 12
coming next year - COM based (see above)
- Requires Excel to run and build
- Possibly opens up security concerns
- Only supported on Windows
.NET using 3rd party tools (Aspose is an example)
Pros
- Fastest generation method seen. Faster than
COM by probably 1000x - Able to run simultaneous threads
- Easy to code and edit in Visual Studios due to
intellisense support - Object model is simple and easy to use
- Random cell access
Cons
- Requires 3rd party product ($400) plus
Visual Studios - Requires a non-SAS language
- Only supported on Windows
Next up: web services and SAS data.
Friday, January 13, 2006
SAS and Processes
On SAS-L today was a debate over macros vs whatever else or whether a user should learn macros early, late, never, sometime. I have nothing against macros but I do have an issue with the idea that SAS code generation is exclusively the domain of macros and SCL. I also don't think users should ever be held back on what they should or should not learn. No bounds in programming is my motto and the point of this blog entry.
Awhile back I wrote a program that was entirely in C# and just generated SAS format code. This provided the users with a great little graphical utility that generated valid format statements from various data sources (http://savian.net/utilities). Why? To do this in SAS would require Access engines, would not be graphically rich, and wouldn't allow the drag and drop stuff that I like.
This is where I think the SAS community can benefit: asking "how do I do this today and is there a better way?". I'm not saying it's right but that it provides an alternative view for how to accomplish a given task. The more we know the more we will embrace macros, embrace perl, embrace C#, embrace wild stuff like LINQ. The more you play, the more you will be able to help the end users.
Ok, I'm heading back to left field now...
Tuesday, January 10, 2006
Approach to Excel and SAS
The approach I typically advocate is:
1. Use SAS to get your data in shape.
2. Write a .NET program and use the SAS OleDB provider to read in the dataset. This sample code will turn your SAS dataset into a .NET datatable.
internal DataTable LoadSasDataSet(string sasLibrary, string sasDataSet)
{
DataTable dt = new DataTable();
OleDbConnection sas = new OleDbConnection("Provider=sas.LocalProvider; Data Source=" + sasLibrary);
sas.Open();
OleDbCommand sasCommand = sas.CreateCommand();
sasCommand.CommandType = CommandType.TableDirect;
sasCommand.CommandText = sasDataSet;
OleDbDataReader sasRead = sasCommand.ExecuteReader();
dt.Load(sasRead);
endTime = DateTime.Now;
return dt;
}
3. Download the Aspose Excel .NET model. It can be found at www.aspose.com . While this ultimately will cost around $400, it is worth every penny if you do this a lot.
4. Write your .NET code. There are loads of examples on the Aspose site.
This approach is simply fast, fast, fast and is very powerful. You have full formatting control over the sheet, random access to anywhere on the sheet, and it is simple to code once you get started. Depending on the level of formatting, sheets should be created in less than 1ms plus Excel is not needed to create the sheets.
While learning 2 languages and keeping up on them has its complexities, I think you will find the above to be worth the time. What you will get out is a powerful tool to create Excel worksheets from your SAS data.
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:...
-
I am finally ready with my SAS dataset reader/writer for .NET. It is written in 100% managed code using .NET 3.5. The dlls can be found here...
-
Well, around 14 months ago, I started on a journey to understand the SAS dataset so I could read and write one independently. Originally, I ...
-
I was just tasked to read in LDAP records so we could cross-reference userids with login identifiers and general ledger information. Using...