BookmarkSubscribeRSS Feed
bouz22
Calcite | Level 5

Hi all,

 

I am using the following code to export csv files from our Sasapp server to a shared network drive:

 

%lET export_directory_RDP = G:\Exports;

%MACRO EXPORTDATA_RDP(DATA);
 %global download_to_rdp download_from;

%let dsempty=0;
data _null_;
  if eof then
    do;
     call symput('dsempty',1);
     put 'NOTE: EOF - no records in data!';
    end;
  stop;
  set &DATA end=eof;
run;

%if &dsempty. %then
    %do;
      %put WARNING: Export step skipped - no output records.;
    %end;
  %else
    %do;
		/* Data to export */
		%let lib  =         work;
		%let datafile =     &DATA;

		/* Local folder to download to */ 
		%let download_to_rdp =  &export_directory_RDP;
		 
		/* detect proper delim for UNIX vs. Windows */
		%let delim=%sysfunc(ifc(%eval(&sysscp. = WIN),\,/));
		 
		/* specify a wildcard to export all csv files*/
		%let download_from =
		  %sysfunc(getoption(work))&delim.%str(*).csv;
		 
		filename src "%sysfunc(getoption(work))&delim.&datafile..csv" encoding = "utf-8";
		 
		proc export data=&lib..&datafile.
		  DBMS = dlm  
		  outfile=src
		  LABEL
		  replace;
			DELIMITER = ";";
		run;

		filename src clear;
    %end;
%MEND;

and the following export step:

bouz22_0-1611313628435.png

This works very well but when my colleagues try to open the exported files the get the following error message:

Cannot read file G:/Exports/filename.csv: Permission denied.

 

Interestingly, it seems that some files that I exported today have today as creation date while others have the creation date in the past. The files with a creation date in the past do not show the permission error...

 

Does anyone have an idea of what is going on here?

1 REPLY 1
bouz22
Calcite | Level 5

It looks like this is actually a problem with moving the files afterwards as they retain the permissions from the previous directory instead of inheriting them from the directory they were moved to..

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 953 views
  • 0 likes
  • 1 in conversation