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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 1 reply
  • 793 views
  • 0 likes
  • 1 in conversation