Copy files from local PC to SAS server in Enterprise Guide - sas

I need to extract a particular sheet from a .xls file on my local machine and get it as a .sas7bdat files on the SAS server on which I work (or the other way round, that is, import it and then convert).
The problem is that although this can be done using the Import Wizard, I need to do this using the 'Copy Files Add-in' because it needs to be built as a part of an automated process.
When I tried doing this using the copy files add-in, it DID copy the .xls file onto the server according to the log, but the .xls file didn't actually show in the library and could not be referenced either (or maybe I'm just referencing it wrongly).
This has led me to believe that I need to convert it to a .sas7bdat and then import it.
Is there a way to get past this? Please bear in mind that I am talking about an automated process, so the wizard is useless for me (or is it? I'm not sure)
NOTE : I am extremely sorry that I cannot post the log and screenshots here, because I work as an offshore resource for a very large bank and cannot post anything here. I have, however, tried to make my problem as clear as possible. If any further clarifications are needed, please let me know!

I assume you've read There and Back Again which covers this in some detail.
Ultimately, all you're doing is copying the excel file as a file onto the SAS server. You're not importing it into a SAS dataset. You would import it by placing the file (either the remote file after copy files add-in, or the local file) in the workflow as an import step.
For example, if you chose /usr/lib/sasdata/myexcel.xls as the remote copy destination, you then need to include that file in your workflow as an import step (you can drag/drop the file and it will automatically create that step for you, with some wizardry).

Related

Interacting with local PC files, SAS EG 7.1

I'm struggling to find a solution to this problem.
The import/export wizard works fine from SAS for pathing to static local and shared drive file locations.
I get stuck trying to use PROC EXPORT so save multiple datasets to different sheets in an Excel workbook for retention policies.
I thought I found a solution that would be great. Referencing a LIBNAME to a local file.
When I run:
""LIBNAME x xlsx 'C:\Users\xxxx\Desktop\EXISITING_CONSOL.xlsx';""
I get confirmation it worked, but when I reference it or try to view it in the Servers navigation window it errors out.
NOTE: Libref X was successfully assigned as follows:
Engine: XLSX
Physical Name: C:\Users\xxxx\Desktop\EXISITING_CONSOL.xlsx
Current version: 9.04.01M3P062415
Operating System: LIN X64
---SAS/ACCESS Interface to PC Files
I would like to use this library method but I'm indifferent to a solution as long as I can save the datasets to a folder path through my PC that I can F3.
I appreciate any direction!
The issue you have here is that SAS can't actually see your c:\users\... folder, unless you have a share set up (and since the SAS Server is on Linux, it would have to have a different structure anyway). The "Import wizard" actually imports it locally (using some .Net code in Enterprise Guide) and then uploads the data to the SAS server.
The normal way this is handled is for you to use a network share that both SAS and your local PC can see - often something like \yourcompany.com\sharename\foldername\ or similar.
If you don't have something like this, then you can use the "Copy Files" task in Enterprise Guide to copy files down locally that are on the server. See this blog post about it.

SAS - How to configure sas to use resources from local disk other than local disk C:

Basically when I do sorting or join table in sas, the sas will use resources / space from local disk C: to process the code, but since I only have 100GB left on local disk C:, It will result in error whenever SAS was out of resources.
My question is how to configure / change the setting in SAS to use resources from Local Disk E: instead, since I have larger space there.
I already looking through the forum, but found no similiar question.
Please Help.
Assuming you are talking about desktop SAS, or a server that you administer, you can control where the work and utility folders are stored in a few ways.
The best way is to use the -work and -utilloc options in your sasv9.cfg file. That file can be in a few places, but often the SAS Shortcut you open SAS with specifies it with the -CONFIG option. You can also set the option in that shortcut with -WORK or -UTILLOC command line options. The article How SAS Finds and Processes Configuration Files can help you decide the location of the sasv9.cfg you want to modify; if you are using a personal copy on your own laptop, you may change the one in the Program Files folder, but if not, or if you don 't have administrative rights, you have other places you can place a config file that will override that one.
A paper that discusses a few of these options is one by Peter Eberhardt and Mengting Wang.
One way is to set up a library named user for projects that will be time intensive and this way you get it to be dynamic as needed. When you have a library called user, that becomes the default workspace instead of work. But, you need to clean up that library manually, it won't delete data sets automatically when you're done with it.
libname user '/folders/myfolders/demo';
As #Tom indicates, you can also set an option to use a library that already exists if desired.
options user = myLib;
An advantage of this method over the config file method as it only does it for projects where it's needed, rather than your full system.

Can Enterprise Guide delete local files?

I know that recent versions of EG can copy files between a SAS server and the local Windows filesystem. But is there any way of getting EG to delete a file as a step in a process flow?
Assuming you're running EG connected to a server that does not have access to your local PC, I don't believe you can without using .NET or something inside EG. You cannot do something like run an X command or similar, because SAS is not on your local machine and can't access it.
It should be possible however to script (using .NET) an extension to EG to do something like this, though (the same way the copy files extension was originally written). But it wouldn't be a SAS process.
Note: The original task was described in a blog post by Chris Hemedinger; that post did not however describe how to actually write such an extension beyond detailing that it uses SAS Workspace APIs. You might look into that first.

XLS/XLSX to CSV in c++

I've been given a project in which I need to import data from CSV, XLS and XLSX files, do some processing, then write the results to a database.
I'm working on a project that's been going on for a while and there are several import functions already that use a very nice object to handle opening files with all sorts of separators and such. And this object is key to the processing that I need to perform.
Since a CSV is basically a textfile with a different extension this object opens it perfectly and I've managed to complete most of the processing and testing with the object and values stored within.
But now I need to add the XLS and XLSX support. And since this object is now pretty much central to the processing I figured the easiest way to fit XLS and XLSX files in would be to convert them to CSV, then import that.
Any help would be appreciated and I'll try answer questions if it's necessary, but since the request is just for some way to convert from one file type to another and nothing more insightful I don't think it's really necessary to add any snippets just yet.
Your options in terms of C++ libraries:
OpenXLSX - https://github.com/troldal/OpenXLSX
XLNT - https://github.com/tfussell/xlnt
Or you could give "XLSX I/O" a try. It's a small C library.
"XLSX I/O" - https://github.com/brechtsanders/xlsxio
Don't forget to add the usual extern "C", when calling C functions from C++.
The repo contains basic xlsx-to-csv (and csv-to-xlsx) examples, which should get you started: https://github.com/brechtsanders/xlsxio/blob/master/src/xlsxio_xlsx2csv.c
Maybe this will help:
http://www.codeproject.com/Articles/42504/ExcelFormat-Library
Also you can use libraries from Open/Libre Office project.

What is the consequence of using my own autoexec.sas file?

I want to write my own autoexec.sas file, but I don't want to lose any functionality that I might have had from the default autoexec.sas file(s).
When I do a SASHome directory search, I find many files with this name. Do all of these files execute by default after the SAS system initializes? Or just one of the files?
Where do I save my own autoexec.sas file so that the other files still execute, along with my own?
Just starting here. Thank you very much.
You really shouldn't edit the usermods file. When you upgrade versions you'll lose all of your changes. There's actually a specific autoexec file designed just for this purpose -- autoexec_usermods.sas
That's where you'll want to keep your site specific modifications -- this way when you upgrade versions your transition will be relatively seamless.
I think you will want to edit these 3 usermods files:
opt-biserver-Lev1-SASMeta
opt-biserver-Lev1-SASMeta-MetadataServer
opt-biserver-Lev1-SASMeta-WorkspaceServer
The following links from SAS documentation should help answer your question on impact, storage and order of execution of autoexec file :
Customizing Your SAS Session by Using Configuration and Autoexec Files
Files Used by SAS -> SAS Autoexec File