BookmarkSubscribeRSS Feed
gurbeer
Calcite | Level 5

I want to run a SAS program as a windows service in Windows Server 2008 R2 on SAS 9.3.
I have written a sample SAS code that creates a data set test in C drive as follows:

libname path "C:\";

data path.test;
result = "Through service";
run;

 

Next, I'm trying to create a SAS Service using SAS Service Configuration Utility as per the following linkhttp://support.sas.com/documentation/cdl/en/hostwin/63047/HTML/default/viewer.htm#n11p2kzepqm4abn1f2.... Kindly refer to the attached screenshot for the parameters.

Below are the different variations that I have used as the service path:

1. "E:\SASHome\SASFoundation\9.3\sas.exe" -SYSIN "C:\MyPgm.sas"

2. "E:\SASHome\SASFoundation\9.3\sas.exe" -noterminal -SYSIN "C:\MyPgm.sas"

3. "E:\SASHome\SASFoundation\9.3\sas.exe" -noterminal -SYSIN "C:\MyPgm.sas" -config "E:\SASHome\SASFoundation\9.3\nls\en\SASV9.CFG"

 

In all the scenarios, I'm getting the following error:

 

"Windows could not start the SAS_service service on local computer.
Error 1067: The process terminated unexpectedly."

 

Any help in this regard would be highly appreciated.
Thanks


Error.jpg
12 REPLIES 12
gurbeer
Calcite | Level 5

Actually, I had thought so and that's why I logged on to the server and tried to run the serevice manually. Still the same error.

Kurt_Bremser
Super User

Did you try

E:\SASHome\SASFoundation\9.3\sas.exe -SYSIN C:\MyPgm.sas

(no quotes needed, as there are no blanks in the file/pathnames) straight from the commandline? And what messages did you get?

SASKiwi
PROC Star

Try running your test program as a batch job from a Windows command prompt. Does it work OK?

gurbeer
Calcite | Level 5

@SASKiwi, I have tried what you have asked. It works as expected - creates a data set test at desired location. Refer to the attached screenshot for the same.

 

@Kurt_Bremser, I have also tried what you have asked and it still didn't work. However, in the bat file created, I have not used quotes - you can refer to the screenshot, and it worked fine.


Error1.jpg
SASKiwi
PROC Star

Since your batch job test worked OK I think that confirms that you are invoking SAS correctly.

 

What happens if you add a statement using the SLEEP function to your test DATA step - telling your program to sleep for 5 minutes (RC = sleep(60 * 5); ). Does your Windows service continue OK for 5 minutes then stop or does it still stop immediately?  

gurbeer
Calcite | Level 5

@Kurt_Bremser, since service isn't getting started, SAS isn't even getting invoked - so no logs in this case.

@SASKiwi, I'd say my understanding here is that since SAS isn't even getting invoked, so introducing sleep or for that matter changing anything in the data step may not be helpful as my SAS code isn't even getting executed. I believe firstly, I need to be able to invoke SAS from Services.

SASKiwi
PROC Star

What about your user account? Do you have appropriate admin rights to create a Windows service?

 

 

Kurt_Bremser
Super User

@gurbeer wrote:

@Kurt_Bremser, since service isn't getting started, SAS isn't even getting invoked - so no logs in this case.

 


I was not talking about what happens when you run it as a service, I was talking about running it from the commandline directly.

gurbeer
Calcite | Level 5

@SASKiwi, I'm not very sure about whether I have rights to start a service or not. I'm able to create one, so, I assumed I can simply start one too. But then, shouldn't that give an error saying something similar to rights required to start a service or something?

@Kurt_Bremser, I was able to run it through commandline and generate a log file as attached, which says the data set created successfully.


Log.jpg
Kurt_Bremser
Super User

I just googled the 1067 error, and it seems to indicate that the service in question (SAS in your case) exited with an exit code <> 0.

My next tries would be

- write a simple .bat that echoes some text into c:\test.txt

- try to run that as a service

- if that works, add the SAS command line in the batch file, capture the exit code immediately after, and echo that to C:\test.txt

- see which exit code came from SAS.

 

I have to say, though, that I am always astonished by how complicated such simple tasks are in Windows. By $DEITY, am I glad my SAS server runs on UNIX!

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

CLI in SAS Viya

Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 12 replies
  • 2249 views
  • 0 likes
  • 3 in conversation