How to automate SAS EG 4.1 program daily and put the output in Excel and run VBA and print PDF? - excel

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.

Related

Running SAS programs from excel

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/

User option in Access to select unique filepath for Excel source data

I am working off of a great solution created by #MattHall from 2011 to a question that I also shared about importing a dynamic range from Excel into Access.
Specific to that--though in general for future VBA's--my question is whether there is an additional way to be able to point to the Excel source file if it is moved without having to go into the VBA editor every time?
For my specific needs, I am trying to work on these Access and Excel files with others through a shared BOX that has a different file path for whoever is working on it.
USER 1 may be: C:\Users\USER1\Box Sync\filename.xlsx
USER 2 may be: C:\Users\USER2\Box Sync\filename.xlsx
...and so forth for any other users. I am curious how we can all work off this when the file path used in the VBA created and used by USER1 is not accessible by USER2? Could there be some code that allows for the every user to locate the file each time through their own filepath?
It would be a pain to do that but I also do not know a better option as we are not working off a shared server and this is unfortunately limited to Box share at the moment.
EDIT: If anyone could also suggest how to integrate their recommendation into the 'Dynamic Range' code in solution from #MattHall in the linked Stackoverflow, that would particularly helpful to my request.

I am looking for an example to collect GA data from Excel using VBA

I have tried to find a way to get Google Analytic data into my Excelsheet using VBA, I can find a lot of information, but it seems to be either depricated April 30 2015 or comercial, and I only want it for my private project...
The best point I have found is this:
http://analytics.blogspot.se/2009/08/analytics-data-in-excel-through-our-api.html
Right now I collect data from GA as a csv file, add my VBA script and run my function, but it would be a lot nicer to be able to collect it directly from my workbook...
Frankly I think Selenium is your best chance for automated collection of data from GA. It could work as follows:
Create a simple Python script where Selenium downloads the csv file from GA
From your workbook run the script using Shell ("python your_script.py")
Next upload the csv file to your workbook e.g. via ADODB.Connection
Google Sheets has a really user-friendly and feature rich integration with GA via the Google Analytics Spreadsheet add-on. You can run regular, automated reports this way and export as CSV if you like.

Search directory for single file and add file to zip

I'm wondering if this is possible and the best way to accomplish it if it is.
Scenario: We have multiple sites that create a "dated subdirectory" each day at a certain time. The dated subs contain information for that day of business.
I need to pull a single DBF file out of the dated sub each day and either export the data to an ever-expanding Excel file, that contains information from the single DBF file from EACH day so it looks like:
Day 1's information
.
.
.
Day 2's information
.
.
.
Day 3's information
OR
Add a copy of the DBF file from each dated sub to a ZIP file that is done daily.
The name of the DBF file never changes, and can't be deleted.
I'm thinking it could be done with a forfiles command, but am curious if it could be done more efficiently. The file that searches, pulls, and zips would be run as a task nightly.
As an add-on, could it be pushed to a Google Drive for safe storage?
Sorry if this is rambling. This is something I'd love to try to do, but not sure where to start exactly.
-Dated sub created nightly, single file from that directory needs to be pulled or read and transferred either to an Excel file or copied to a ZIP with a way to seperate each file, maybe a directory with date as name?
Also, if able, it needs to start with a particular date, like 6/1/2014 but no further back.
Thanks in advance for any help.
Can you merge data from a DBF file to an Excel file? Not really with pure batch, but you can use JScript or VB Script. You'll need the MS ACE OLEDB 12.0 driver. Then you can use a connection string for DBF and another for XLSX. (If you're using XLS or CSV, you could get by with the MS Jet driver, running the WOW64 version of cscript.) Once connected, just use SQL queries. SELECT * FROM dbffile, and as you're looping through the recordset, INSERT INTO xlsxfile.
Can you append a DBF file to a zip file? Probably. I'm guessing 7za.exe a will append to the archive if the archive already exists. Try it and see. Or were you wanting to script the zip functionality without 3rd party software?
Can it be copied to a Google Drive? Well, yeah, the Google Drive software watches and mirrors a folder on your hard drive. So chances are, copying the file to %userprofile%\Google Drive\ will do what you want without any conscious effort.
Try posting another question. But rather than rambling again, find one specific problem where you're getting stuck, and explain what you've tried without success.

Need a office 2007 Macro for the below situation?

Here is the situation: We have a mobile app which sends the data entered/captured by user through email to any email client selected by the user. Data/attachments consists of one .csv(excel file) and .jpg file(may be 1to3 pics).
Basically we have automated the manual report filing (before automation, folks use manual report filing using normal/manual paper filing technique).Now i want to create a good looking report in ms word or in excel(if later is not possible) from what i have sent(attachments)to the email.
Few links to give you guys a hint about the target doc file and excel file with attachment.
Excel file: http://i1117.photobucket.com/albums/k596/hitmanx07/Excel.png
Doc file: http://i1117.photobucket.com/albums/k596/hitmanx07/Doc.png
Need a automated solution so that every time user downloads the data from email he/she could possibly change the downloaded excel file into a doc(see attached).
Hope i'm clear
mrana...
Here is the solution for above:
Ms-office Excel's Macros is the solution for this issue. Basically Macros work in such a manner that what steps user performs on excel to solve the issue have been recorded by macros and then user can perform same task within seconds which if done manually could take so many time by use of that recorded macros.
So basically its an automation technique.
Please use this link to see how to deal with all these things.
http://www.csus.edu/training/handouts/workshops/Excel07pivot&macro.pdf
gracius.

Resources