We’re smarter together. Learn from this collection of community knowledge and add your expertise.

Automating SAS using VBScript

by Frequent Contributor on ‎12-10-2015 03:59 PM (784 Views)

I recently wrote a paper on automating SAS using VBScript. I wanted to share this here, as it has dozens of applications. 


VBScript and SAS are each powerful tools in their own right. These two technologies can be combined so that SAS code can call a VBScript program or vice versa. This gives a programmer the ability to automate SAS tasks, traverse the file system, send emails programmatically, manipulate Microsoft® Word, Excel, and PowerPoint files, get web data, and more. This paper presents example code to demonstrate each of these capabilities.


If you like it, please check out my other papers, downloads, and subscribe to my free bimonthly e-magazine.






by Super User
on ‎12-11-2015 04:55 AM

An interesting article, thanks for sharing.  I would point out two things however:

With VBScripting, there are a few considerations.  Firstly you can seriously damage your system/filesystem etc. if things go wrong, this is one of the main reason why X command is sometimes denied bythe IT group.  I wouldn't want to see novice users writing scripts to do things when they either don't understand it, or don't follow appropriate procedures - testing, documentation etc.  It can be quite dangerous.  Also, I have had it before where a vendor sends through a project which includes scripts calling VBAscripts and they fail, different versions or missing components etc.  Robustness should be at the forefront of development.


Secondly need.  With the office applications they already have VBA embedded in them.  Often we have these questions of how to update a pre-existing file with new data.  My answer is always to write VBA code to import a CSV file and process it into the spreadsheet.  This is very simple code and can be stored in the same file.  Just reduces the number of technologies needed.  Of course in an ideal world you wouldn't be using office for anything anyways, use a proper report format or data transfer format and that solves all these issues straight away.  The reliance on Excel (in particular) is one of the biggest holes in technology worldwide.


Your turn
Sign In!

Want to write an article? Sign in with your profile.

Looking for the Ask the Expert series? Find it in its new home: communities.sas.com/askexpert.