-
May 22nd, 2011, 11:12 AM
#1
How to 'Call a SAS Program routine in C# program?
Hello,
I am not a .NET or C# programmer at all. But I had to work on this project which has a C# program which is running some SAS code in that.
The current code in the .CS program is:
--------------------------------------------------------------------------------
public System.Data.DataSet GetLibraries(string ADUser)
{
object obj3;
Connection activeConnection = this.GetConnection();
string aDGroups = this.GetADGroups(ADUser);
string str2 = "select distinct lec || ' ' || lib as lib, libpath from lib.adxlibpath";
Recordset aDODBRecordSet = new RecordsetClass();
Command command = new CommandClass();
command.ActiveConnection = activeConnection;
command.CommandText = @"libname lib 'C:\sas\sasdata'";
object missing = Type.Missing;
command.Execute(out obj3, ref missing, -1);
command.CommandText = "create table temp as " + str2 + " where ADGroup in (" + aDGroups + ")";
command.Execute(out obj3, ref missing, -1);
aDODBRecordSet.Open("temp", activeConnection, CursorTypeEnum.adOpenUnspecified, LockTypeEnum.adLockUnspecified, -1);
OleDbDataAdapter adapter = new OleDbDataAdapter();
System.Data.DataSet dataSet = new System.Data.DataSet();
adapter.Fill(dataSet, aDODBRecordSet, "libraries");
activeConnection.Close();
return dataSet;
}
--------------------------------------------------------------------------------
In this code, a SAS code is being run which creates a table called 'TEMP' which is used as input in the further 'public' codes.
Now, I need to change this piece of code to call a SAS code routine residing on our server instead of embedding the code in this C# program.
Can anyone please let me know how can I do that?
What I tried is in the secode 'string' statement above, I just defined str2 = "%INC \\path\program.sas" and given 'command.CommandText = str2'. Obviously this is not working
I am not at all into C# programming. If you can help me do this task, that would be greatly appreciated.
Thanks much guys!
Regards,
BK.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|