Hi all,
I have a quite simple question (... i think).
(probably i am a litte bit rust ? :D)
I have a path name that's look like : %let path=&root./chemin/toto & titi/data.txt;
...and i don't want SAS to resolve the second & , the one of toto & titi, because that's the real path name.
any idea ? %str, %superq...
Do not edit results. The code you show for the path cannot generate the shown result because it does not have the word "General".
Also you have apparently removed where that macro variable is actually used. That is part of the code that should be included and the complete log where the macro variable is used.
Code and log results should be pasted into text boxes opened on the forum with the </> icon that appears above the message windows. We have no idea what software you may be using to create pictures and what artifacts it might insert into the image.
Suggestion:
Run this code:
%let root=C:\Users\chemin; %let fic_OneDrive=&root.\%nrstr(toto &titi); %put fic_OneDrive resolves to: &fic_OneDrive.;
Copy the result text from the log and paste into a text box (don't make a picture). It should look like this with different line numbers:
203 %let root=C:\Users\chemin; 204 205 %let fic_OneDrive=&root.\%nrstr(toto &titi); 206 207 %put fic_OneDrive resolves to: &fic_OneDrive.; fic_OneDrive resolves to: C:\Users\chemin\toto &titi
You picture shows characters that do not appear in the text previously. If they do not appear as in the above then it is likely that you may have gotten some invisible characters some how. Retype the code for the entire %let statement in that case.
%let path=&root./chemin/toto %nrstr(&) titi/data.txt;
it put en error 😕
Show us the code you used. Show us the LOG for this code.
Code and logs should be provided as text and not as screen captures.
We need to see enough of the code to know how it is used.
Do not edit results. The code you show for the path cannot generate the shown result because it does not have the word "General".
Also you have apparently removed where that macro variable is actually used. That is part of the code that should be included and the complete log where the macro variable is used.
Code and log results should be pasted into text boxes opened on the forum with the </> icon that appears above the message windows. We have no idea what software you may be using to create pictures and what artifacts it might insert into the image.
Suggestion:
Run this code:
%let root=C:\Users\chemin; %let fic_OneDrive=&root.\%nrstr(toto &titi); %put fic_OneDrive resolves to: &fic_OneDrive.;
Copy the result text from the log and paste into a text box (don't make a picture). It should look like this with different line numbers:
203 %let root=C:\Users\chemin; 204 205 %let fic_OneDrive=&root.\%nrstr(toto &titi); 206 207 %put fic_OneDrive resolves to: &fic_OneDrive.; fic_OneDrive resolves to: C:\Users\chemin\toto &titi
You picture shows characters that do not appear in the text previously. If they do not appear as in the above then it is likely that you may have gotten some invisible characters some how. Retype the code for the entire %let statement in that case.
Please show your full code and log, it can be just a small example reproducing the problem.
%NRSTR() should work, but there are situations where a symbol hidden by %NRSTR can be automatically un-hidden.
I did a simple test, and it worked fine:
%let path=Q:\Junk\%nrstr(foo&bar.txt) ;
filename foo "&path" ;
data _null_ ;
infile foo ;
input ;
run ;
Log is:
1 %let path=Q:\Junk\%nrstr(foo&bar.txt) ; 2 3 filename foo "&path" ; 4 5 data _null_ ; 6 infile foo ; 7 input ; 8 run ; NOTE: The infile FOO is: Filename=Q:\Junk\foo&bar.txt, RECFM=V,LRECL=32767,File Size (bytes)=48238, Last Modified=06Sep2024:15:51:56, Create Time=06Sep2024:15:50:38 NOTE: 1950 records were read from the infile FOO. The minimum record length was 0. The maximum record length was 146.
Having an ampersand (which has special meaning for UNIX systems) in a file or directory name is not good (and I am being extremely polite here!)
In naming stuff in your filesystem, allow only letters, digits, underlines and dots. No blanks or other special characters.
@blast wrote:
i totally agree with you Kurt.
thank you for being so polite.
unlucky Sometimes, you're not the one who choose such directory names 😄
Yep. When our IT set up our OneDrive storage we had to include a "OneDrive - XXX" in the path of every file (all work product must be on OneDrive).
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!
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.