BookmarkSubscribeRSS Feed
AngSAS
Fluorite | Level 6

Hi SAS Users,

 

I was wondering if anyone has come across similar issue as I am; and if so, what the solution was.

 

I use SAS Enterprise Guide, and one of the task I am working on requires me to edit Excel 'Sheet Name'. I could not find any solution that can be scripted within SAS, so I created a VBScript that does the sheet rename task. When I run this VBScript via command prompt it works but when I try to run it via Enterprise Guide, it does not work (need this to run via SAS for automation). It does not throw any error but does not run either (i.e. does not rename the sheet).

I have tried following three methods that I found online, but same result with all of them.

 

Method 1 (running command line code using sysexec):

%sysexec cscript "\\filepath\filename.vbs";

 

Method 2 (creating bat file to run command line code, and using x command to run the batch file):

FILENAME script "\\filepath\filename.bat";

 

DATA __NULL__;

FILE script;

PUT 'cscript "\\filepath\filename.vbs"';

RUN;

 

X script;

 

Method 3 (running the pipe command to run batch file):

filename oscmd pipe '"\\filepath\filename.bat" 2>&1';

 

data _null_;

infile oscmd;

input;

put _infile_;

run;

 

 

I noticed that the Enterprise Guide version in my laptop is 64bit but the SAS Add-In for Microsoft Office is 32bit. Could that be the reason? [VBScript uses WScript.CreateObject("Excel.Application") fuctionality]

Or am I missing something?

2 REPLIES 2
ChrisHemedinger
Community Manager

When running a script with SYSTASK or FILENAME PIPE, it's SAS that runs the script, not EG.  Assuming your SAS is on Windows and can run OS commands, you might want to be explicit about which version of cscript to run:

 

 %windir%\SysWOW64\cscript.exe - 32-bit version of CSCRIPT.exe

 

Chris

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
AngSAS
Fluorite | Level 6

Thanks Chris for your reply.

However, that did not seem to work either.

We ended up eliminating the need to open the Excel file all together by moving all the calculations to SAS from excel.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 3237 views
  • 1 like
  • 2 in conversation