Hi. I'm using SAS EG on a client's server environment. I'd like to know if there's a way to upload an Excel file name people.xlsx from my local computer (stored in c:\temp) to my SAS EG environment folder (e.g. /sasdata/users/steve) from within a SAS program itself?
Or is it possible to directly import the Excel file into SAS from my local computer (c:\temp)?
Essentially I'm trying to eliminate the manual step of transferring the excel file to the SAS server before importing the excel data into a SAS dataset.
Any help insights would be much appreciated.
Yah, that is the manual step I'm trying to automate. I'm wondering if the commands the Copy Files task uses can be called directly from my SAS program so I can just pass the parameter values in my SAS code. But I can't see the code behind the Task to see how it's transferring the file. Do you think automating this task into a SAS program is possible?
Is there anyway to see the code behind a Task?
The Copy Files task doesn't use SAS code (as @JuanS_OCS points out). In general, most tasks do have SAS code that you can examine/copy, but Copy Files is doing the work via your EG->SAS connection, using APIs.
If you want to script this outside of the project, you can use a tool like PowerShell -- example here. This uses the same SAS workspace infrastructure that you already have in place.
Your responses are confusing. You were suggested to use a feature of EG that would let you upload a file. You didn't want to use that for some reason. Then when suggested how to upload without EG you reject it because it is not part of EG.
What was wrong with using the COPY FILES feature of EG?
Sorry if I'm confusing. No disrespect intended. Maybe I can't assume all SAS EG environments are not like mine. I first connect to a Citrix desktop on our client's server and then launch SAS EG from there.
I'm trying to circumvent the Copy Files task because it's a manual step outside of running my SAS program that uses Proc Import to read in the .xlsx file from my SAS EG folder. I was just hoping there was a way to mimic what the task does using some SAS or SAS EG functionality so that I don't have to perform the manual steps of running the Copy Files task.
If you goal is to capture this completely within your SAS program, then your SAS session needs to have access to your local machine - through a mapped drive, network share, or similar mechanism.
In the days of SAS/CONNECT where you have SAS locally and SAS on a remote machine, you could use PROC UPLOAD for this. But without SAS locally, you have to rely on client techniques to upload files to your SAS session. EG has a built-in method, or you can script it from outside of EG.
Yup, that is my goal. The reason I thought this might be possible is because I can manually save and open excel files from within SAS EG. For instance, in SAS EG from the Output tab of my dataset named TMP. I can click Export => Export TMP... then double-click My Network Places => \\client => c$ => temp. Then change the Save As file type to *.xlsx" and click the Save button.
So it seems there is some type of mapping in place, but I guess I just don't know how to use it within my SAS EG code to first move the .xlsx file to my SAS server folder before I use Proc Import to read in the file contents.
I believe that the Import / Export tasks in EG are interactive. A person needs to be there when they run.
But I think the Copy Files task is not. You tell it what file to copy and it always copies that file when it runs.
Is the problem that the filename changes?
When I run the Copy Files task (Tasks --> Data --> Copy Files ...) it prompts me for information like file transfer direction, paths, filenames, etc... by popping up a window. So an alternative would be to be able to call the Copy Files task and pass these types of parameters in from my SAS program rather than by manually clicking thru a series of SAS EG menus and hand entering the values in the pop-up window. Is this method possible?
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.