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

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

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

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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