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 ;
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:
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.";
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
And where is the problem? You use double quotes when specifying the output file for ods, simple as that.
Your code would look like this:
%let fname=data/saswork/file_name.xml; ods tagsets.excelxp file="&fname.";
No need for any additional quotes.
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:
Thanks Chris,
I have seleted this option but the problem remains
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 ;
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
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.