I have a few SAS programs that I need to run from excel. The programs pull tables from SQL, perfom some calculations and give an output table that I would like to present in Excel. So I figured that it would be great to run everything in excel.
There are a few parameters in the code that need to be changed before running, so the best idea I had is to put the SAS scripts in cells on an excel sheet and change the variables with VBA.
My question is, is this achievable? Can I connect to SAS and do everything from excel?
I'm fairly good with VBA, starting to learn SAS, but I don't really know how to connect the two. Thank you for your help!
Yes it is possible , i did this in my work a week ago , SAS have an documentation here?
The link below can help you.
http://documentation.sas.com/api/docsets/itechwcdg/9.4/content/itechwcdg.pdf?locale=en
You can use ADODB to connect to , see here for the strings
https://www.connectionstrings.com/sas/
Your options are:
1) use VBA to connect to IOM, create a workspace, run your program.
This requires quite a bit of VBA, as well as the SAS Addin for MSO, and various components.
2) Run a Stored Process (STP) via point and click using the MSO addin
Again, this requires a desktop SAS Addin deployment, and isn't scriptable with VBA
3) Run a Stored Process as a web query
This is an excellent option - you don't need any special desktop installation, you can easily add (url) parameters, you can use it with / without VBA, and your output will render easily into your worksheet so long as you stream tab delimited data via the _webout fileref (without %stpxxx macros). It will also work with all versions of excel and SAS.
This approach is described here: https://www.rawsas.com/sas-as-a-service-an-easy-way-to-get-sas-into-excel-power-bi-and-000s-of-other-tools-languages/
Related
I am trying to get VBA to access a SAS dataset for use in an excel spreadsheet, there appears to be a specific Method for doing this but I can't get it to work as it keeps giving me an error.
My code as it stands looks like
Sub GetData()
Dim sas as SASExcelAddIn
set sas=Application.COMAddIns.Item("SAS.ExcelAddIn").Object
Dim data as SASDataView
set data =sas.InsertDataFromSASFolder ("path", Sheet1.Range("A25"),25,True,"","",True)
End Sub
The value of Path is a unix path to the folder with the dataset in, I have tried specifying this both with the dataset and without and with the dataset without the file extension but I always get the error:
The only documentation I can find is https://documentation.sas.com/doc/en/amodg/8.3/p11y2jzgivsqw4n1ixw5jjf22obd.htm but it is not solving my issue.
My aim will be to automate this to allow the folder to be changed and the SAS datasets referenced to update to the new data with just a single input. Any ideas why this isn't working?
Thanks
The only thing I can think of, and I don't use VBA with SAS, is this statement: "The data source must be saved in the metadata" at the top. Let me propose an alternative if someone doesn't solve it. Consider using VSTO (C#), vs VBA, and read the SAS dataset using ODBC or OLEDB. Much, much simpler and easier to debug scenario. VSTO allows you to create anything in the ribbon and relies on interop to work with Excel.
Good luck on getting an answer. Consider an alternative if you hit the wall.
I'm using Excel 2016 to access a DDE server (Rockwell Software's RSLinx Classic.) The DDE server is working correctly/can be accessed from other applications. The problem is trying to access it from Excel.
This is what is in my cell: =RSLinx|PS9TOPIC1!'N7:0'
The PS9TPIC1 topic is set up (and works) in RSLinx. RSLinx is up and running. But I get:
Remote data not accessible... Start application RSLINX.EXE?
Clicking Yes gets:
Cannot run 'RSLINX.EXE'. The program or one of its components is missing or corrupted
The program runs fine. I have ensured that RSLinx.exe is on the PATH (Double-checked the PATH for the running Excel using Task Manager.) It doesn't matter whether I have RSLinx running before starting Excel or have Excel try to launch it.
No, the option to "Ignore other applications that use Dynamic Data Exchange" is not checked for this document.
I tried running both RSLinx and Excel as "Administrator" with the same result.
Bringing up the help for data connections shows this:
Note: In an earlier version of Excel, you might have used Dynamic Data Exchange (DDE) in combination with the Step-by-Step Mail Merge Wizard in Word. Excel no longer supports DDE. If you'd like us to consider this feature for the next version of Excel, drop us a comment in the Excel Suggestion Box.
Try using an older Excel license.
I had the same problem, i already solved it. Just go to your project in the kepserver, open properties, and make sure enable the DDE conection to your server... Just that in my case. Good luck..
enter image description here
I am totally new to automation, but trying hard to find answers online everywhere for 1 week. I could not able to do what I wanted to do. I have a SAS enterprise guide 4.1 old version and program runs on a SAS server. I have a SAS report due every day at 9:30 AM. I have the code that is already setup and working fine. I need to automate this program to run at 8:00 AM every day, then move the output to a specific excel file in sheet 1 at specific cell range, then invoke the VBA macro button (UPDATE) placed in the sheet 2 and then print out two worksheets in the same file as a single PDF file to somewhere in my computer. I will have to upload this into a CMS. I wanted to automate until the step before the last step, creating the final PDF report on a daily basis.
When I thought about all these I was stunned. I actually created a batch file in notepad and made SAS to open the file at specific time using Task Scheduler in Windows XP control panel. However, SAS did not run the program.
Here is the batch file code:
Start/w C:\PROGRA~1\SAS\ENTERP~1\SEGuide.exe –sysin "Z:\ccccc\vvvvv\Report.egp"
If anyone could please help me, I would like to know how do I make the SAS to run the program in the SAS server and also where do I provide the user name and password for the SAS server authentication. Can anyone please give me an example how to write this code in my batch file. Also, how to export the output into the specific excel file in SHEET 1 and then run the VBA macro. Then how to print out PDF files of two worksheets as a single file and place the final PDF file in the C:\Report folder.
I am sorry it is too much information, but if someone could help me figure out, I would really appreciate all your help!
Park
Enterprise Guide automation is a bigger issue than can be covered in a StackOverflow answer in detail. In general, EG exposes itself to automation through a DLL (SASEGScripting.dll), which you can then automate using VBScript, Powershell, or .NET (C# etc.). You need to read the documentation for the API or read a tutorial.
Chris Hemedinger has several good explanations of how to go about doing this; for example, see this article, or browse his blog articles.
My employer is considering installing OpenOffice.org's suite of Office products instead of using Microsoft Office. I've written several advanced applications in Access and Excel, and I'm trying to figure out what will and will not be compatable with OpenOffice.org.
Specifically, what do I need to do to have Calc (OpenOffice.org's version of Excel) read and execute VBA in macro's and tie macro events to button clicks?
Also of note, I'm using the MySQL Connector from within Excel to dynamically update data in the spreadsheet. What might I need to do to preserve data connectivity to our MySQL server?
Thanks
As far as I know, OOo Base can connect to an mdb file to the extent that it can open tables and queries. I think anything else - forms, reqportes, macros VBA and native - would need to be redeveloped.
I don't believe that OOo Calc can read or execute VBA: it has its own dialect of Basic, which has a variant syntax. It doesn't, as far as I can tell, support the concept of Class, for example. Some work appears to be occurring, however, see the OpenOffice Wiki for more information. Right now, I'd say you should be planning on a careful and complete rewrite.
Regarding the MySQL connector - I'd say that's the least of your worries...
On the plus side, you're likely to have real job security for a year or two while you get everything ported!
I recently discoverd go-oo which seems to be able to achieve your task.
I am stuck with a problem
The Requirement is that, there a complex Excel file(XLS) that is used as template; it has Macros and all the worksheets are either locked or hidden. When the user clicks to download it, the follows operation occurs
Unlock a particular worksheet, fill some data # certain cells and then lock it back.
Unhide a worksheet, fill some data # certain cells and then hide it back.
I think there are two options to resolve it (if there are more then please let me know)
Interop libraries / Excel Object Library
OLEDb Driver
I cannot got with the option 1 as excel is not installed on the webserver and I heard that it's not a good option to install MSOffice # webserver.
My question is that can we use OLDb to perform the operations mentioned above OR is there any other option ???
BTW Sharepoint service is also not available :(
Please help!!!!
You could maybe try ExcelPackge.
See this article:
Server-Side Creation of Excel 2007 Files Using .NET 3.0 and Office Open XML
see also:
Office Space - Building Office Open XML Files
Check out this question I asked some time ago for an overview of options. I ended up going with the Aspose library, which I link to in my original post. It's not cheap, but it does the job very simply and elegantly. It even has templating functionality built in (called SmartMarkers, IIRC).
SpreadsheetGear for .NET will handle this and has an API which is very similar to Excel. You can see what our customers say and download the free, fully functional evalution here.