Ok, well the major issues have been tackled except 1. How do you handle spaces in your NameValuePairs? Well, without the single quotes below, it kept splitting the values between the Sample and the Data. The single quotes hold it together.
Check this out:
string[] parms = new string[2]
{
"outdata=WORK.ALAN_20110418_070053",
@"datalib='X:\Data\Prognos\DemandForecasting\Sample Data'",
};
Notice the single quotes around the value? It took a long time to track that one down (thanks ThotWave).
Now it is simple to submit to SAS:
string newParms = string.Empty;
if (parms != null)
{
newParms = String.Join(" ", parms);
}
StoredProcessService sp = Common.SasLanguageService.StoredProcessService;
sp.Repository = storedProcLibrary;
sp.Execute(storedProcedureName, newParms);
I would ask R&D a simple question which is why isn't there an option on the SPS to specify the delimiter or am I missing a flag somewhere?
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.
Monday, April 18, 2011
Our journey with SAS's StoredProcessService object continues...
Check out this code:
string newParms = "outdata=WORK.TEST";
Common.SasLanguageService.Async = true;
StoredProcessService sp = Common.SasLanguageService.StoredProcessService;
sp.Repository = storedProcLibrary;
sp.Execute(storedProcedureName, newParms);
Standard stuff when working with the stored process server through VB or C# (or any other means of hitting these dlls).
Funny thing is the SAS log shows that the macro assignment of newParms never takes place. Hence, &outdata is undefined:
SYMBOLGEN: Macro variable OUTDATA resolves to
Commenting out the Async makes this all work:
SYMBOLGEN: Macro variable OUTDATA resolves to WORK.ALAN_20110418_070053
Now, even wiring up the event handlers for SubmitComplete do not fix the issue. Seems like a bug but I'll let the guys in R&D figure it out. If you have to waste a lot of time on it, however, keep in mind the nuances here until SAS R&D dives in.
Well, back out to the far left field where I hang out. Time to work on the business problem.
string newParms = "outdata=WORK.TEST";
Common.SasLanguageService.Async = true;
StoredProcessService sp = Common.SasLanguageService.StoredProcessService;
sp.Repository = storedProcLibrary;
sp.Execute(storedProcedureName, newParms);
Standard stuff when working with the stored process server through VB or C# (or any other means of hitting these dlls).
Funny thing is the SAS log shows that the macro assignment of newParms never takes place. Hence, &outdata is undefined:
SYMBOLGEN: Macro variable OUTDATA resolves to
Commenting out the Async makes this all work:
SYMBOLGEN: Macro variable OUTDATA resolves to WORK.ALAN_20110418_070053
Now, even wiring up the event handlers for SubmitComplete do not fix the issue. Seems like a bug but I'll let the guys in R&D figure it out. If you have to waste a lot of time on it, however, keep in mind the nuances here until SAS R&D dives in.
Well, back out to the far left field where I hang out. Time to work on the business problem.
This one is a real Keeper
So, if you ever get this error while trying to work with OleDb and SAS IOM:
The object ... could not be found; make sure it was previously added to the object keeper
Make sure that you include the following lines (the lack of a Keeper is what causes this error):
ObjectFactory factory = new ObjectFactory();
ServerDef server = new ServerDef();
Workspace ws = (Workspace)factory.CreateObjectByServer("ws", true, server, "", "");
ObjectKeeper keeper = new ObjectKeeper();
keeper.AddObject(1, "SASServer", ws);
That whole ObjectKeeper is missing from a number of examples that I have seen and it is critical for everything to function. It becomes apparent when trying to get the data from an OleDb DataAdaptor.
The object ... could not be found; make sure it was previously added to the object keeper
Make sure that you include the following lines (the lack of a Keeper is what causes this error):
ObjectFactory factory = new ObjectFactory();
ServerDef server = new ServerDef();
Workspace ws = (Workspace)factory.CreateObjectByServer("ws", true, server, "", "");
ObjectKeeper keeper = new ObjectKeeper();
keeper.AddObject(1, "SASServer", ws);
That whole ObjectKeeper is missing from a number of examples that I have seen and it is critical for everything to function. It becomes apparent when trying to get the data from an OleDb DataAdaptor.
Subscribe to:
Posts (Atom)
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 was just tasked to read in LDAP records so we could cross-reference userids with login identifiers and general ledger information. Using...
-
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 ...