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

Hello,

 

I would like to know if there is a way to disable (properly) false warning?

 

On my current project, I have to write dynamically few dos batch with variables thanks to the SET.

But SAS keeps warning me with the "WARNING: Apparent invocation of macro P_ROOT not resolved." because of this :

 

%let myBat = &path_2_script.\copy.bat;

data _null_;
  file "&myBat." encoding="WLATIN1";
  length line $1024;
  put "echo off";

  line = cats("SET P_ROOT=", "&myRoot.");
  put line;
run;

data _null_;
  set l_folder_2_check;
  file "&myBat." mod;
  length line $1024;

  line = cat("MKDIR ""%P_ROOT%\_", trim(target_env), "_\", trim(current_folder), """ 2>NUL");
  put line;
run;
/**
  I get here the warning because of the DOS var %P_ROOT%

After the MKDIR, I have a dynamic COPY instructions... Once the script is done, when I call it with a X command, I get also new warning... (one for each call of %P_ROOT% lol) **/

I have tried all the options I know, googled also for it without any satisfying solution...

 

Thx for reading

 

Michel

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Try instead of

"MKDIR ""%P_ROOT%\_"

 

'MKDIR ""%P_ROOT%\_'

 

Single quotes should block attempted resolution of macro

 

 

View solution in original post

6 REPLIES 6
ballardw
Super User

Try instead of

"MKDIR ""%P_ROOT%\_"

 

'MKDIR ""%P_ROOT%\_'

 

Single quotes should block attempted resolution of macro

 

 

Astounding
PROC Star

As @ballardw noted, single quotes prevent any activity by the macro processor, including trying to locate a macro named %P_ROOT.  However, that change needs to be applied in a few areas of your program.  Consider this line, for example:

 

line = cat("MKDIR ""%P_ROOT%\_", trim(target_env), "_\", trim(current_folder), """ 2>NUL");

 

You would need to change the first parameter to CAT, to use single quotes as the outermost quotes:

 

line = cat('MKDIR "%P_ROOT%\_', trim(target_env), "_\", trim(current_folder), """ 2>NUL");

 

k4minou
Obsidian | Level 7
Thx both of you =} I'll try tomorrow

Cheers
BrunoMueller
SAS Super FREQ

If it is just about creating a directory have a look at the DCREATE function.

k4minou
Obsidian | Level 7
Thx for the function but no it's not only about creating directories =}
k4minou
Obsidian | Level 7

Works like a charm

 

Thank all of you 😃