BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
blast
Fluorite | Level 6

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

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

 

 

View solution in original post

11 REPLIES 11
PaigeMiller
Diamond | Level 26
%let path=&root./chemin/toto %nrstr(&) titi/data.txt;
--
Paige Miller
blast
Fluorite | Level 6

it put en error 😕

PaigeMiller
Diamond | Level 26

Show us the code you used. Show us the LOG for this code.

--
Paige Miller
blast
Fluorite | Level 6

blast_0-1726154233244.png

 

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
ballardw
Super User

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.

 

 

blast
Fluorite | Level 6
Ok, it works today 🙂
thanks for your help, i don't know why yesterday it didn't (an issue with symbolgen , don't know..)

Merci beaucoup 🙂 and have a great week-end



Quentin
Super User

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.
The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
Kurt_Bremser
Super User

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
Fluorite | Level 6
i totally agree with you Kurt.
thank you for being so polite.
unlucky Sometimes, you're not the one who choose such directory names 😄
ballardw
Super User

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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 1315 views
  • 1 like
  • 5 in conversation