CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2011
    Posts
    3

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

  2. #2
    Join Date
    May 2011
    Posts
    3

    Re: How to 'Call a SAS Program routine in C# program?

    Hmmm... can anyone respond to this query please? This is a huge project for me and I am able to do nothing so far.

    Also, how can we pass parameters from C# to SAS routine that I will be calling in C#?

    Thanks a lot.

  3. #3
    Join Date
    May 2011
    Posts
    3

    Re: How to 'Call a SAS Program routine in C# program?

    Neva mind. I've got solution to my issue. Did seek some help or at least documentation referrals from the experts of 'The number one developer site!', but may be everyone is busy

    Cheers anyways....

  4. #4
    Join Date
    May 2011
    Location
    Washington State
    Posts
    220

    Re: How to 'Call a SAS Program routine in C# program?

    Did you not consider that perhaps you just didn't have anyone come accross your post that does anything with "SAS program routines"? If I haven't done it, I'm not going to waste your time querying you further on it... just a thought...
    Last edited by fcronin; May 27th, 2011 at 06:31 PM.

  5. #5
    Join Date
    Nov 2012
    Posts
    2

    Re: How to 'Call a SAS Program routine in C# program?

    Bharath, Can you help me how to call a SAS program/macro. Please throw some light. Sample program will helps.

    -Bhaskar

  6. #6
    Join Date
    Aug 2008
    Posts
    78

    Re: How to 'Call a SAS Program routine in C# program?

    What is SAS routine?
    What error are you getting?

  7. #7
    Join Date
    Nov 2012
    Posts
    2

    Re: How to 'Call a SAS Program routine in C# program?

    I want to call a batch file. But Batch file can not run from ASP.net program So I am planing to call the .sas file from ASP.net using IOM. That .sas file contains macros also. Any Idea how to call a .sas from ASP.net page?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured