BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Frn747
Calcite | Level 5

Hi there.

 

I am trying to create a folder for my output reports and I have tried all of these options:

%put NOTE: creating folder (%sysfunc(dcreate(Reports, ParentDir)));

%put NOTE: creating folder (%sysfunc(dcreate('Reports', 'ParentDir')));

%put NOTE: creating folder (%sysfunc(dcreate("Reports", "ParentDir")));A

At least, one of them should be correct but in all of the cases, the output is the same:

NOTE: creating folder ()

No output directory, no errors, no nothing. Just a blank string (and of course, the folder has not been created).

 

I am working in a pretty restricted environment (SAS 9.3) and I can't use either shell escape commands (like X or SysExec). Probably my problem is due to some other admin restriction but: no output at all? nothing? not an error or a warning?

 

Any clue?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@Frn747 wrote:

Thank all for your suggestions.

 

I think that the key information and probably I don't explain it clearly enough is that I am trying to create the folder in my local machine, not in the server!

 

 


That is a fairly key distinction, EG is likely on your server and cannot see or access your local machine. So you cannot pass commands to your local machine in this manner, UNLESS you can select run locally in EG. Even then you cannot have local and server processes in the same process flow.

View solution in original post

10 REPLIES 10
andreas_lds
Jade | Level 19

The documentation of dcreate says: "If the directory cannot be created, then DCREATE returns an empty string."

If you are using dcreate with %sysfunc, you need to use macro-variables, if "ParentDir" is a dataset-variable, don't use %sysfunc.

 

Frn747
Calcite | Level 5

Thanks Andreas for your reply.

 

I already tried with macro-variables and with a data step with the same result:

%let newdir = 'Reports';
%let parentdir = 'C:\Users\Public\Documents\SAS Learning\';
%put NOTE: creating folder (%sysfunc(dcreate(&newdir, &parentdir)));

data _null_;
	new = dcreate('Reports', 'C:\Users\Public\Documents\SAS Learning\');
	put "NOTE: creating folder (" new ")";
run;

I have rights in that folder. I have no clues why the directory cannot be created!

Frn747
Calcite | Level 5
No, I didn't.
I only use Enterprise Guide and I don't think I can log on to the SAS server (or at least, I don't know how to).
Tom
Super User Tom
Super User

Don't put quotes into macro variables, unless you need the quotes in the strings you are generating.

Make sure that the parent directory exists on the machine where SAS is running. Try FILEEXIST(). And is a directory and not a normal file try DOPEN().

andreas_lds
Jade | Level 19

@Frn747 wrote:

Thanks Andreas for your reply.

 

I already tried with macro-variables and with a data step with the same result:

%let newdir = 'Reports';
%let parentdir = 'C:\Users\Public\Documents\SAS Learning\';
%put NOTE: creating folder (%sysfunc(dcreate(&newdir, &parentdir)));

data _null_;
	new = dcreate('Reports', 'C:\Users\Public\Documents\SAS Learning\');
	put "NOTE: creating folder (" new ")";
run;

I have rights in that folder. I have no clues why the directory cannot be created!


The first try won't work due to using quoted strings, as @Tom  already said. The data-null-step should work, if the path C:\Users\Public\Documents\SAS Learning\ exists on the server. The blank in "SAS Learning" could cause trouble, that's why i hardly every use blanks in filenames or directory-names.

Frn747
Calcite | Level 5

Thank all for your suggestions.

 

I think that the key information and probably I don't explain it clearly enough is that I am trying to create the folder in my local machine, not in the server!

I already have the reports generated in the server but I need to download them to my local machine. I am using the "Copy Files" add-in but it needs the folder to exist and I can't figure out how to ensure the folder exist and if not, create it.

 

Tom
Super User Tom
Super User

@Frn747 wrote:

Thank all for your suggestions.

 

I think that the key information and probably I don't explain it clearly enough is that I am trying to create the folder in my local machine, not in the server!

I already have the reports generated in the server but I need to download them to my local machine. I am using the "Copy Files" add-in but it needs the folder to exist and I can't figure out how to ensure the folder exist and if not, create it.

 


Then you need to edit the code of the Copy Files add-in. Which is NOT SAS code.

Reeza
Super User

@Frn747 wrote:

Thank all for your suggestions.

 

I think that the key information and probably I don't explain it clearly enough is that I am trying to create the folder in my local machine, not in the server!

 

 


That is a fairly key distinction, EG is likely on your server and cannot see or access your local machine. So you cannot pass commands to your local machine in this manner, UNLESS you can select run locally in EG. Even then you cannot have local and server processes in the same process flow.

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
  • 10 replies
  • 1206 views
  • 0 likes
  • 5 in conversation