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..

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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