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

hello ,

I would like (dummy example) to get the text 'hellobye' in a macro varaible. by running this code, the result in the log is

'hellobye GOPTIONS NOACCESSIBLE'. how to prevent the text "GOPTIONS NOACCESSIBLE" to be inserted ?

Thanks a lot in adance

regards

Nasser

%let text1 = hello ; 
%let text2 = bye ;
%let text3 = %str(%')&text1.&text2.%str(%') ;
%put &text3 ;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

Macro best practices aside...

 

If you are using SAS Enterprise Guide and you want to suppress this GOPTIONS statement, select the option from Tools->Options->Results, Graph panel:

 

suppress.png

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

View solution in original post

8 REPLIES 8
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Its really not a good idea to put quotes of any kind in a macro variable, as you can tell just from the snippet you post it really makes coding and quoting so much harder and there is no reason for it.

%let text1 = hello ; 
%let text2 = bye ;
%let text3 = &text1.&text2.;
%put "&text3.";
Nasser_DRMCP
Lapis Lazuli | Level 10

thanks a lot RW9, but I need the ' to specify the file (with its folder) in ODS TAGSETS like this

ODS TAGSETS.EXCELXP FILE = "&file." ;

 

how could I obtain this

ODS TAGSETS.EXCELXP FILE = 'data/saswork/file_name.xml' ;

by loading the folder and the file in a macro variable ?

thanks

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Your code would look like this:

%let fname=data/saswork/file_name.xml;

ods tagsets.excelxp file="&fname.";

No need for any additional quotes.

ChrisHemedinger
Community Manager

Macro best practices aside...

 

If you are using SAS Enterprise Guide and you want to suppress this GOPTIONS statement, select the option from Tools->Options->Results, Graph panel:

 

suppress.png

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
Nasser_DRMCP
Lapis Lazuli | Level 10

Thanks Chris,

 

I have seleted this option but the problem remains

Kurt_Bremser
Super User

The problem is your use of quotes in macro variables, which is VERY BAD practice, as you just experience. It's just that additional code ends up in there, because SAS has problems finding the end of the string. This additional code is sent as "opening" and "closing" wrapper around your code by EG.

Now there are ways to make this work, but it's much easier to wrap quotes around text where they are needed, not where the text is defined.

EG

%let text1 = hello ; 
%let text2 = bye ;
data _null_;
call symput('text3',"'&text1.&text2.'");
run;

%put &text3 ; 

 

Nasser_DRMCP
Lapis Lazuli | Level 10

Kurt,

 

by lauching your code , the result is  'hellobye GOPTIONS NOACCESSIBLE'

i succeed to prevent the GOPTIONS NOACCESSIBLE only by closing and restart sas EG.

thanks all for your help

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 8 replies
  • 7740 views
  • 2 likes
  • 4 in conversation