Proc SQL SAS Export to CSV throwing access error - sas

I have a set of code that keeps throwing an error and can't figure out why;
ERROR: Insufficient authorization to access
/sas/config9_4/compute/Lev2/SASApp/\VA019\F01B\Everyone\B_ADHOC\MWDATA\Student_D_Repor
t_20190416.csv.
ERROR: Insufficient authorization to access
/sas/config9_4/compute/Lev2/SASApp/\\VA019\F01B\Everyone\.......
PROC EXPORT OUTFILE="\\VA019\F01B\Everyone\B_ADHOC\MWDATA\Student_D_Report_&mToday..csv"
DATA= Student_D_Report
DBMS=CSV REPLACE;
run;
I was exporting to xlsb in excel format and it was working fine. Code below
PROC EXPORT OUTFILE="\\\VA019\F01B\Everyone\B_ADHOC\MWDATA\Student_D_Report_&mToday..xlsb"
DATA= Student_D_Report
DBMS= EXCELCS REPLACE;
SHEET='DEBIT';
run;
Thoughts?

It appears you had been running SAS EG connected to localhost and writing to Windows network share \\VA019. The error appears as if you are now connected to a SAS server running on Unix and trying to write to the same Windows network share, and the Unix box login is trying to use the old Windows network share.
You will either need to either:
export to a Unix folder (/tmp or a subfolder under your login) and download the csv to PC via EG
ask your Unix admin to mount the VA019 windows share in Unix and give you rights to write to it.
In either case the code running in Unix hosted SAS will have to change the proc export outfile= path.

Related

How to copy files from a SAS server to my local computer?

I am trying to copy files from a folder on a SAS server to my local computer, I am trying to run the following codes connected to the server, and also disconnected from the server, but I am not getting positive results.
infile '/SASPrueba/Prueba_ALH/Libro1.xlsx';
file '/C:/Test/Libro1.xlsx';
input;
put _infile_;
run;
%sysExec move "\SASPrueba\Prueba_ALH\" "\C:\Test\";
I would appreciate if anyone knows how to perform this copying.
Most of the time, the SAS server cannot access your local machine's disks, unless you've set up a network share, which is not the case in most settings. You should instead use a network folder that both you and the SAS server can see, and place them there.
However, if you have access to Enterprise Guide, there is a task that lets you do this: the Copy Files task. It's built into SAS Enterprise Guide as of 7.13 (late 2017).
SAS Studio also has a similar option built in, "upload" and "download" in the Server Files and Folders tab.
You cannot execute either of these directly through SAS code, though - these are both point-and-click options.
If you really want to use SAS to do this rather than using an SFTP tool as per Tom's suggestion, you could try proc download:
rsubmit yourserver;
proc download
infile = '/SASPrueba/Prueba_ALH/Libro1.xlsx'
outfile = 'C:\Test\Libro1.xlsx'
binary
;
run;
endrsubmit;

SAS DS2 code doesn't work with a remote server

I'm getting errors when running PROC DS2 code to read a large data set residing on a different server. The LIBNAME statement uses a remote engine. SAS currently doesn't have a driver that can read remote data sets. PROC DS2 uses drivers not engines. This is not available yet in base sas as the documentation claims. SAS told me they will add a defect for their R&D. If anyone knows a work around on how to run DS2 code on a remote server please share your code. I use a remote server because the data is huge and wanted to use DS2 to minimize job run time.
proc ds2;
data test201/overwrite=yes;
method run();
set {select * from randlib.Tax_prd};
end;
enddata;
run;
These are the errors.
LIBNAME randlib '/username/sasfile' server = XXXX; NOTE: Libref RANDLIB was successfully assigned as follows: Engine: REMOTE Physical Name: /username/sasfile
LIBNAME randlib '/username/sasfile' server = XXXX; NOTE: Libref RANDLIB was successfully assigned as follows: Engine: REMOTE Physical Name: /username/sasfile
ERROR: Compilation error. ERROR: BASE driver, schema name RANDLIB was not found for this connection ERROR: Table "RANDLIB.TAX_PRD" does not exist or cannot be accessed ERROR: Line 215: Unable to prepare SELECT statement for table

SAS EG Local submit

rsubmit;
<Code>
endrsubmit;
This is useful if u are connected to the local server and you want to run a code on the remote. But how do I run a local script from the remote server? Is there something equivalent to localsubmit?
Additional Info:
I run most of my codes on the remote server because it is faster but I need to use the local SAS in two instances
There is one location with lots of space that I am unable to access through the remote server. I.e. it can be accessed as I:\folder1\folder2 but not as /folder1/folder2 (I tried finding a shortcut through filezilla but I guess the IT team has not created it)
Proc export with dbms = excel is only possible with a local server without which I cannot export multiple data in the same excel file (Which leads to a mess and would involve changing set processes/architecture that use dbms = excel)
You can only run code locally (on the machine on which EG installed) if you have a Base SAS licence. You will know this is the case if you open your SAS program (in EG), and check the values in the "Selected Server" dropdown. If you have a 'local' option you can run locally.
There is no concept of localsubmit. If you wanted to run code on your machine and trigger it from the server, your local machine would have to be configured as a SAS/Connect server and you would use rsubmit (with appropriate connection profile) from that server to your local machine. This would be a highly unusual scenario!
If I understand properly, at least for the second example there's a fairly common use case here.
What you'd do is to run the main program in rsubmit, and then in non-rsubmit block download the dataset created from the rsubmit block.
libname rwork slibref=work server=<yourserver>;
See this KB article for more information.
Then you could do it easily:
rsubmit server=myserver;
data class;
set sashelp.class;
run;
endrsubmit;
libref rwork slibref=work server=myserver;
data l_class;
set rwork.class;
run;
proc export data=l_class ...;
run;
Or even skip the l_class dataset and directly export from rwork.
For the first scenario, a large part depends on why you can't just not use rsubmit. Is the program located on the remote server, and you can't directly access it? You'd want to talk to IT I guess to find out how to directly access it.

Is it possible to batch process SAS programs from a local machine to a remote server using SAS EG?

I am trying to create a simple UI in SAS EG where users can add their local sas files and batch submit them to a remote server.
If you have local SAS datasets, you probably have a local installation of Base SAS - in which case you can upload the data via SAS/Connect (if installed). Make sure your selected server is 'local' in the EG program editor and run the following (modify as per your site details):
/* prepare credentials */
%let remote = your.server 7551;
%let sasuser = &sysuserid;
%let saspass={sas002}BA7B9D061CA7F9601F317DCA06C4CFCC;
options comamid=tcp remote=remote;
/* signon and assign remote library */
signon sasuat nocscript user=&sasuser password="&saspass";
rsubmit;
libname example (work);
endrsubmit;
libname example (example) server=remote;
/* add a local SAS dataset to the remote library */
data example.ex1;
set sashelp.class;
run;

Can SAS macro variables created in remote session be used in local program submission

Could any one help me in providing any solution to my issue explained below?
I am running some part of the code in SAS which is submitted in remote server. and then I have to export the the created dataset to excel.
so i wrote a export code outside remote submission, but it is not able to use the parameters defined in remote session.
Please provide any work around for this issue.
Thanks in advance.
Pass your parameters back to the local session as follows:
rsubmit;
%put NOTE: running remotely;
%let myvar=&syscp;
%sysrput localvar=&myvar;
endrsubmit;
%put &=localvar;
Remember that your excel export process will need to read your remote data so be sure to use the right library (eg RWORK).