BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
raj712
Fluorite | Level 6

Hi All,

 

I am very new to SAS, so asking this weird queries. 

 

Can someone help me to identify how "Callscoring.log" file is being called? can i replace it with some other file (just as testing purpose)

 

When i am calling sas program from c#, i am getting below error. Please help.

 

ERROR: Insufficient authorization to access C:\Program Files (x86)\Microsoft SQL Server\130\DTS\binn\CallScoring.log.

Also when i tried to run two powershell commands to execute SAS.exe as same time, it throw me error as below.

 

ERROR: File is in use, c:\Users\abc\CallScoring.log
1 ACCEPTED SOLUTION

Accepted Solutions
jimbarbour
Meteorite | Level 14

@raj712,

 

@Quentin's advice is good.  Get the SAS job running properly as just a SAS job first.  I imagine that it's running fine, but it looks like you might need to make a few adjustments.

 

First, when you see this type of error:

ERROR: Insufficient authorization to access C:\Program Files (x86)\Microsoft SQL Server\130\DTS\binn\CallScoring.log.

it's usually because no log path was specified or the path was specified incorrectly.

 

What command string are you using in C# to invoke SAS?  I would like to see the entire command string.  You probably need to put a fully qualified log path in your command string otherwise, SAS will try to write the log to where ever it is invoked from.  If you're invoking SAS from C#, it might therefore be trying to write the log to C:\Program Files (x86)\Microsoft SQL Server\130\DTS\binn.

 

The second error is occurring because you're executing two instances of CallScoring concurrently.  They're both trying to write to the same log.  You need to create a dynamic log file name.  I usually use "directives" to assign such a dynamic name, but you could do it in your C# code.  

ERROR: File is in use, c:\Users\abc\CallScoring.log

 

Here's how I typically do it in my command line string (this is just the log portion of the string):

-log c:\Users\abc\CallScoring_#Y-#m-#d_#H-#M-#s_#p.log

"#Y-#m-#d_#H-#M-#s" places the year-month-day-hour-minute-second into the filename of the log file.  #p places the Windows process ID into the file name which guarantees that the name will be unique and should eliminate the "File is in use" error.

 

Jim

View solution in original post

3 REPLIES 3
Quentin
Super User

Hi,

Can you show more of your log?  The part before those error messages?

 

If you are calling a SAS program CallScoring.sas, SAS would typically create CallScoring.log which is a log file from the SAS session.  By default it's usually placed in the directory where the .sas file is located.  It's odd that it would try to write to:

C:\Program Files (x86)\Microsoft SQL Server\130\DTS\binn\

If it's possible a process has lock on the .log file, that might explain the second message.  You would just need to find out what program is locking it.

 

Before trying to call the program from c#, I would try to get it working just as a SAS batch job.  Since you're on windows, testing that is probably as easy as right-clicking the .sas file and selecting 'batch submit.'  Get that working first, so you know the SAS part is working.  Then go back to calling it from c#.

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
jimbarbour
Meteorite | Level 14

@raj712,

 

@Quentin's advice is good.  Get the SAS job running properly as just a SAS job first.  I imagine that it's running fine, but it looks like you might need to make a few adjustments.

 

First, when you see this type of error:

ERROR: Insufficient authorization to access C:\Program Files (x86)\Microsoft SQL Server\130\DTS\binn\CallScoring.log.

it's usually because no log path was specified or the path was specified incorrectly.

 

What command string are you using in C# to invoke SAS?  I would like to see the entire command string.  You probably need to put a fully qualified log path in your command string otherwise, SAS will try to write the log to where ever it is invoked from.  If you're invoking SAS from C#, it might therefore be trying to write the log to C:\Program Files (x86)\Microsoft SQL Server\130\DTS\binn.

 

The second error is occurring because you're executing two instances of CallScoring concurrently.  They're both trying to write to the same log.  You need to create a dynamic log file name.  I usually use "directives" to assign such a dynamic name, but you could do it in your C# code.  

ERROR: File is in use, c:\Users\abc\CallScoring.log

 

Here's how I typically do it in my command line string (this is just the log portion of the string):

-log c:\Users\abc\CallScoring_#Y-#m-#d_#H-#M-#s_#p.log

"#Y-#m-#d_#H-#M-#s" places the year-month-day-hour-minute-second into the filename of the log file.  #p places the Windows process ID into the file name which guarantees that the name will be unique and should eliminate the "File is in use" error.

 

Jim

raj712
Fluorite | Level 6

Thanks @Quentin and @jimbarbour. I just explicitly passed log file location to command and it worked. Thanks a lot.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 649 views
  • 2 likes
  • 3 in conversation