BookmarkSubscribeRSS Feed
buechler66
Barite | Level 11

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.

16 REPLIES 16
JuanS_OCS
Amethyst | Level 16
Hi,

Try Tasks --> Data --> Copy Files ...
buechler66
Barite | Level 11

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?

JuanS_OCS
Amethyst | Level 16
No if you don't have SAS in your client machine, in your PC, since the server, who will run the SAS code, has no knowledge of your PC.

But I am sure you can automate with other kind of scripts and tools, such as sftp, or of you have visibility, such as a samba share from your server in your PC.

buechler66
Barite | Level 11

Is there anyway to see the code behind a Task?

JuanS_OCS
Amethyst | Level 16
Not really, as far as I know of.
However, the task will be a component of your SAS EG project. And a SAS project is a binary file, not a text file as SAS programs are.
But Projects can be scheduled to run as per your request, if you have such capability in your PC.
In this way you can automate the uploading of a file of certain files from your PC to the server.
ChrisHemedinger
Community Manager

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.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
buechler66
Barite | Level 11
This is really interesting, but I don't see how I can use this to upload a
.xlsx from c:\temp to my sas eg folder (e.g. /sasdata/users/blxn) from
within an interactive SAS EG program.

Correct me if I'm wrong, but this looks like it's a script that is executed
on the local computer side and executes SAS code on the server side from
which the output file is save also to the local computer.
Tom
Super User Tom
Super User

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?

buechler66
Barite | Level 11

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.  

ChrisHemedinger
Community Manager

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.  

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
buechler66
Barite | Level 11

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.

Tom
Super User Tom
Super User

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? 

buechler66
Barite | Level 11

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?

Tom
Super User Tom
Super User
I think that is the disconnect. When you use EG it is in charge, not the SAS process. So EG can send code to SAS to run but SAS cannot send code to EG to run. The puppet cannot control the puppeteer.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 16 replies
  • 12315 views
  • 8 likes
  • 4 in conversation