Error in reading SAS files - sas

I am just playing around with SAS, writing the following code
options nocenter nonumber;
data vag;
infile "C:\Users\Deborah\Desktop\School\STA 318\book\veggies.txt";
input Name $ Code $ Days Number Price;
CostPerSeed = Price / Number;
run;
The location of the file is correct, but the error I am getting
ERROR: Physical file does not exist, /opt/sasinside/SASConfig/Lev1/SASApp/C:\Users\Deborah\Desktop\School\STA 318\book\veggies.txt.
What can I do to fix this?

You are working on Unix server, not you local PC. While you are running a local client on your PC (like SAS EG), you can't actually access local resources on your local PC because these resources needs to be made available to Unix box itself.
You have four options:
1. Use an import Wizard in SAS EG. It will generate a data step and will use hidden SAS EG methods to convert your text file and move it as a data set to Unix server where you then can create variables that you want.
See if your file system is available to you in SAS EG. Expand your workspace server. You should see "files". Expand to the folder that you are allowed to use and drag&drop your text file into there.
Upload files to the unix server using whatever file transfer method is available. Usually you would have some sort of FTP server running.
Also, as Joe suggested, you can install this custom task http://blogs.sas.com/content/sasdummy/2012/12/06/copy-files-in-sas-eg/
It can do a lot better job that step 2 or 3 because it can be part of your process, resolve macro variables and fix file formatting issues between Windows and Unix. Thanks Joe!!

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.

Copying files from one directory to another in SAS EG is not working

I am trying to copy files from one directory to another in SAS EG, but it was not working.
The basic idea in here is to convert .xlsm file to .xlsx file.
%sysexec( copy "&path.\excel1.xlsm"
"&path.\excel1.xlsx" ) ;
I didn't get any error in SAS EG, but nothing happen (no file copied), does anyone know the reason?
Make sure that your SAS session has the XMCD option turned on.
XCMD Enables the X command in SAS.
You can use PROC OPTIONS or GETOPTION() function to see the current setting. This option must be set when the session starts so you might need to modify the server you are connecting to with Enterprise Guide to one with the option turned on (or modify the configuration of the server).
Also make sure that the command and path you are using will work on the server where your SAS code is running. You can look at some of the automatic macro variables like SYSSCP, SYSHOSTNAME and SYSHOSTINFO to see the operating system where SAS is running.
22 %put &=sysscp &=syshostname &=syshostinfolong ;
SYSSCP=WIN SYSHOSTNAME=XXXXXX SYSHOSTINFOLONG=X64_10PRO WIN 10.0.18362 Workstation
If you still have issues you can also use another method to run your command where you will be able to more easily see the messages that the operating system might generate. For example using the PIPE filename engine.
data _null_;
infile %sysfunc(quote(copy "&path.\excel1.xlsm" "&path.\excel1.xlsx" 2>&1)) pipe;
input;
put _infile_;
run;

Using PROC EXPORT in SAS Enterprise Guide 6.1 - OUTFILE path

I am trying to use PROC EXPORT in SAS Enterprise Guide 6.1, through the Citrix environment, to send datasets to Excel, however seem to be having problems with the paths of the files.
The code that I have is as follows:
proc export data = work.Test
outfile = '\\servername\path\Test.xls'
dbms = xls replace;
sheet = "Test";
run;
The error message that I receive is "ERROR: Insufficient authorization to access /sasconfig/compute/ciapp/Lev1/CIApp/\servername\path\Test.xls."
The path I am providing is being appended to another path that I have not defined. Note, the server name is not an alias such as "C:", it is actually the path of the server, but I have removed it for confidentiality.
If I change the line to:
outfile = 'H:/Test.xls'
the error message is "ERROR: Physical file does not exist, /sasconfig/compute/ciapp/Lev1/CIApp/H:/Test.xls"
but if I change the line to:
outfile = '/Test.xls'
the error message is "ERROR: Insufficient authorization to access /Test.xls."
I think I fundamentally am not understanding the file paths that SAS is trying to use. What am I doing wrong/how can I determine a path where I can actually export an Excel file to?
Citrix is probably using UNIX style paths instead of Windows style paths. So instead of \\servername\path you would use //servername/path. h:\ might also be correct (but not h:/) if your SAS server has h:\ defined (not the EG location - has to be where sas.exe actually runs).
SAS EG is an interface to work on a server. If your data resides on the server, you would need to find the full network path to your computer's C drive. Otherwise, you could just change the server in EG to "local" and run everything locally so it would recognize the paths as local.
So if you have a shared drive user (typically not C:), that you can read/write to, you can use properties of a folder on that shared drive to retrieve full path and use that to export. Similarly, you should be able to open network, find the network name of your PC on there and use a relative path like \sharedservername\users\yourusername\subfolder\path\ as an export path.
You can also look at SAS EG's Export wizard's automatically generated code for a dummy export to your path and reuse that code. It will probably retrieve and write the appropriate full path for you.

Sas workspace on SaS EG

We have default SAS workspace of x TB. We also have alternate 10X TB workspace on same server at different folder location.
Can anyone please help me with syntax that can be used in SAS EG to point to the alternate workspace instead of default one?
The SAS work directory can be changed for individuals by creating a $HOME/sasv9.cfg file and placing one line in it:
-WORK {full path to the SAS work directory}
if you are running in unix, you can change the work directory in the execution. nohup sas -work /myworkdirectory mypgm.sas &
Are you referring to the SAS work library, which is the location where SAS lets you store temporary data sets?
If so, then it depends. Are you using EG to in a client/server setup? In that setup you will have to get your SAS Admin to make changes on the server or in the SAS Metadata to point the work library for all Workspace Servers that start to use the other location that has more available space.
Would you not define SAS libraries out of these workspaces?
i.e. libname mydata '/folders/myfolders/'
This will then assign each library to your active SAS session.
Use this as precode to any manipulation your doing.
If you have Management Console, or Using PROC METADATA you can create permanent libraries.
You mentioned workspace, so I assume you need to control the WORK library.
Use the SAS system option
options work=library-specification
In the SAS documentation it states: specifies the libref or physical name of the storage space where all data sets with one-level names are stored. This library must exist.
Make sure the the file space is "close" to where the processing is done or file transfer will be a bottleneck.