BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RAVI2000
Lapis Lazuli | Level 10

I was trying to create a SDTM Domain using macros. I wanted to give a permanent path to store. I use %let path = "Locaton of the path";

and then %include "&path\Location of the path";

and i get an error 


7 option mprint mlogic symbolgen source source2;
8 %let path = C:\Users\jasti\OneDrive\Desktop\Sdtm\DS;
9 %include "&path/C:\Users\jasti\OneDrive\Desktop\Sdtm\DS.sas";
SYMBOLGEN: Macro variable PATH resolves to C:\Users\jasti\OneDrive\Desktop\Sdtm\DS
WARNING: Physical file does not exist, C:\Users\jasti\OneDrive\Desktop\Sdtm\DS\C:\Users\jasti\OneDrive\Desktop\Sdtm\DS.sas.
ERROR: Cannot open %INCLUDE file C:\Users\jasti\OneDrive\Desktop\Sdtm\DS/C:\Users\jasti\OneDrive\Desktop\Sdtm\DS.sas.

 

I just started learning  macros. I know i am doing dumb wrong here. Can anyone help me where am going wrong in giving the path ? 

option mprint mlogic symbolgen source source2;
%let path = C:\Users\jasti\OneDrive\Desktop\Sdtm\DS;
%include "&path/C:\Users\jasti\OneDrive\Desktop\Sdtm\DS.sas";

This was the only code i started with and got error. 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
mklangley
Lapis Lazuli | Level 10

In your code, you're calling the path twice (once in the macro variable &path, once in the typed-out path). The two paths are being concatenated, which produces a non-existent path.

 

WARNING: Physical file does not exist, C:\Users\jasti\OneDrive\Desktop\Sdtm\DS\C:\Users\jasti\OneDrive\Desktop\Sdtm\DS.sas.
ERROR: Cannot open %INCLUDE file C:\Users\jasti\OneDrive\Desktop\Sdtm\DS/C:\Users\jasti\OneDrive\Desktop\Sdtm\DS.sas.

Try changing your %include line to this:

 

 

%include "&path\DS.sas";

 

 

View solution in original post

7 REPLIES 7
Reeza
Super User

ERROR: Cannot open %INCLUDE file C:\Users\jasti\OneDrive\Desktop\Sdtm\DS/C:\Users\jasti\OneDrive\Desktop\Sdtm\DS.sas.

 

Look at your error and look at what you coded. It literally takes the path and puts it where you have &path so it becomes the statement above. This is not valid SAS code. That's the key to making macros initially - treat it as basic text/code generation and the code must be valid SAS code. So if you remove one of the paths below it will work, either the macro variable or the path that you've hard coded. You only need one.

 

%let path = C:\Users\jasti\OneDrive\Desktop\Sdtm\DS;
%include "&path/C:\Users\jasti\OneDrive\Desktop\Sdtm\DS.sas";
mklangley
Lapis Lazuli | Level 10

In your code, you're calling the path twice (once in the macro variable &path, once in the typed-out path). The two paths are being concatenated, which produces a non-existent path.

 

WARNING: Physical file does not exist, C:\Users\jasti\OneDrive\Desktop\Sdtm\DS\C:\Users\jasti\OneDrive\Desktop\Sdtm\DS.sas.
ERROR: Cannot open %INCLUDE file C:\Users\jasti\OneDrive\Desktop\Sdtm\DS/C:\Users\jasti\OneDrive\Desktop\Sdtm\DS.sas.

Try changing your %include line to this:

 

 

%include "&path\DS.sas";

 

 

Patrick
Opal | Level 21

Look at the path that gets generated:

WARNING: Physical file does not exist, C:\Users\jasti\OneDrive\Desktop\Sdtm\DS\C:\Users\jasti\OneDrive\Desktop\Sdtm\DS.sas.

 

Would your code eventually work if you just use the &path macro variable?

%include "&path\DS.sas";
Kurt_Bremser
Super User

You repeat the path in the %INCLUDE statement. I would start with

%let path = C:\Users\jasti\OneDrive\Desktop\Sdtm\;
%include "&path.DS.sas";

If that does not do it, please post the %INCLUDE statement that worked before you used the macro variable.

Astounding
PROC Star

Assuming that the file really does exist, you just need to spell it correctly.  Change the "/" to "\".  Then this combination would work (but would be somewhat confusing):

 

%let path = C:\Users\jasti\OneDrive\Desktop\Stdm\DS;
%include "&path..sas";

This would be more straightforward:

%let path = C:\Users\jasti\OneDrive\Desktop\Stdm;
%include "&path\DS.sas";
RAVI2000
Lapis Lazuli | Level 10
Thank you all for really explaining it in depth and providing possible solutions. I resolved it !
Reeza
Super User
Please select an answer and mark this question as solved.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 7 replies
  • 1014 views
  • 7 likes
  • 6 in conversation