We crated a C# wrapper that calls a SAS stored process that takes more than an hour.
The stored process finished, and I can see that on the sas side, but it never returns a message back to the wrapper that it finishes.
Anyone have something working that you can share?
What the wrapper is doing is:
.
UserContext userContext = CreateUserContext(metadataServer, port);
StoredProcess storedProcess = new StoredProcess(userContext, storedProcLocation);
storedProcess.SetPromptValue("thread_id", thread_id);
storedProcess.SetPromptValue("connect_source", sourceDsn);
storedProcess.SetPromptValue("connect_destination", destDsn);
storedProcess.SetPromptValue("HIST_DATE", HistoryDate.ToString("MM/dd/yyyy"));
storedProcess.SetPromptValue("POS_DATE", PositionDate.ToString("MM/dd/yyyy"));
storedProcess.SetPromptValue("pRunType", pRunType);
storedProcess.SetPromptValue("p_model_type", modelType);
Execution execute = storedProcess.Execute();
return LogStoredProcessResult(execute, storedProcLocation);
When it runs Execute() it never returns.
Thanks
Richard
Hi Alan, thanks for your answer.
When you say Close any Open process, do you mean in the SAS side? or in the API ?
Richard
Thanks Alan. Here is the Method I am invoking.
The SAS process is working fine, is this Method that Execute the SAS process, that does not pass to the next line
after
Execution execute = storedProcess.Execute();
when the STored Process takes long time to execute.
If I change the value on parmeter modelType to for example Factor, that makes the SAS stored process to compute less rows, and in that case the EXECUTE() method returns fine.
my problem is when the stored process takes more than an hour. It process on the SAS side but looks like the Execute method is timing out.
This is the code on my Method in the wrapper.
using System;
using System.Web.Services;
using SAS.BI.AuthenticationService.ClientUserContext;
using SAS.BI.StoredProcessService;
using SAS.BI.StoredProcessService.Exec;
using SAS.BI.StoredProcessService.IO;
using System.Configuration;
using System.Collections.Generic;
[WebMethod]
public bool RunStressGenDataModel(int HistoryOffsetDays, int PositionOffsetDays)
{
log.LogDebug("--------------------------------------------------------");
log.LogDebug("Starting RunGenModelStress");
string metadataServer="cpwnpsas01.corp.capitalpower.com";
string thread_id = DateTime.Now.ToString("yyyyMMddhhmmss");
string pRunType = "Daily";
string sourceDsn = "dsn=Allegro_Stress_Auth;Trusted_Connection=yes;database=allegro_stress";
string destDsn = "dsn=Allegro_Stress_Auth;Trusted_Connection=yes;database=allegro_stress";
DateTime HistoryDate = DateTime.Today.AddDays(HistoryOffsetDays);
DateTime PositionDate = DateTime.Today.AddDays(PositionOffsetDays);
string modelType = "_ALL_VALUES_";
int port = 8561;
UserContext userContext = CreateUserContext(metadataServer, port);
try
{
string storedProcLocation = ConfigurationManager.AppSettings["GenDataModelStress"].ToString();
StoredProcess storedProcess = new StoredProcess(userContext, storedProcLocation);
log.LogDebug(String.Format("RunGenModelStress using location of {0}", storedProcLocation));
/*
* If the parameter names in the Stored Proc ever change, you have to change them here as well
*/
storedProcess.SetPromptValue("thread_id", thread_id);
storedProcess.SetPromptValue("connect_source", sourceDsn);
storedProcess.SetPromptValue("connect_destination", destDsn);
storedProcess.SetPromptValue("HIST_DATE", HistoryDate.ToString("MM/dd/yyyy"));
storedProcess.SetPromptValue("POS_DATE", PositionDate.ToString("MM/dd/yyyy"));
storedProcess.SetPromptValue("pRunType", pRunType);
storedProcess.SetPromptValue("p_model_type", modelType);
Execution execute = storedProcess.Execute();
return LogStoredProcessResult(execute, storedProcLocation);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
Man, I double-posted something and it messed up a few posts so hopefully works right this time (and I am not a DA).
Isolate the issue. Pull that code out to a Console app and try it there to make sure the timeout is not occurring on the web side. Start with that.
Thanks Alan.
One last question. How do you know, looking in some logs in the SAS server, that a stored procedure finish processing. Do you know if SAS log something?
And it which log file.
Richard
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.