<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Macro: Handling Unbalanced Quotations in a SAS Macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Handling-Unbalanced-Quotations-in-a-SAS-Macro-variable/m-p/533178#M146152</link>
    <description>&lt;P&gt;Actually i am using it only in the TITLE statement inside a SAS MACRO, PROC Print I have used to see the Result in the SAS EG. So basically whatever the macro variable holds i have to print it using TITLE statement.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Feb 2019 10:01:29 GMT</pubDate>
    <dc:creator>CC_SAS</dc:creator>
    <dc:date>2019-02-06T10:01:29Z</dc:date>
    <item>
      <title>Macro: Handling Unbalanced Quotations in a SAS Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Handling-Unbalanced-Quotations-in-a-SAS-Macro-variable/m-p/533174#M146149</link>
      <description>&lt;P&gt;Hi Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following data coming through a macro variable, I need to print the data AS IS in the TITLE Statement:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Sample Data:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1Q18-4Q18 CLEARIT UP P25-54 CMT C3&lt;BR /&gt;1Q18-4Q18 GIMMY JOHN'S BANDWATCHES SC P18-49 CMDY C3&lt;BR /&gt;""BANTAGE 3Q18 UBILOFT ""ASSASIN'S CREED ODYSSEY"" UP M18-34 AMTV C3"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;"1Q18-3Q18 PEPPER&amp;nbsp; GROUP ""Terry"" UP P18-34 SPKE C3"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have worked on the&amp;nbsp;&lt;STRONG&gt;single quote &amp;amp; double quote&amp;nbsp;&lt;/STRONG&gt;cases in the IF-ELSE clause.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Commented code is for the DOUBLE Quotes.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Challenges:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;I am unable to run both the cases at once.&lt;/P&gt;&lt;P&gt;2. How do i solve for the string in 3rd Line, i need to print this in TITLE statement AS IS.&lt;/P&gt;&lt;P&gt;Here is the code which I developed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mlogic;
%macro test();
%macro d;%mend d;
%do i=1 %to 3;
proc sql noprint;
select SRCE_DL_NM into :SRCE_DL_NM from data.text where strip(put(sno,8.))="&amp;amp;i.";
;quit;
data dummy;
length SRCE_DL $200.;
SRCE_DL="&amp;amp;SRCE_DL_NM.";
/*SRCE_DL1=&amp;amp;SRCE_DL_NM.;*/
col = CATS("SR_DL",&amp;amp;i.);
x=find(SRCE_DL,"'");
if x &amp;gt; 0 then do;
	SR_DL = cats( '"', SRCE_DL,'"');
	call symputx(col,%bquote(SR_DL)) ;
end;
/*else IF find(SRCE_DL1,'"') &amp;gt;  0 then do;*/
/*	SR_DL = cats( "'", SRCE_DL1,"'");*/
/*	call symputx(col,%nrquote(SR_DL));*/
/*end;*/
else  call symputx(col,SRCE_DL) ;
run;
%put &amp;amp;&amp;amp;SR_DL&amp;amp;i;
proc print data=sashelp.cars(obs=1);
TITLE &amp;amp;&amp;amp;SR_DL&amp;amp;i;
run;
%end;
%mend();
%test();&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 09:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Handling-Unbalanced-Quotations-in-a-SAS-Macro-variable/m-p/533174#M146149</guid>
      <dc:creator>CC_SAS</dc:creator>
      <dc:date>2019-02-06T09:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro: Handling Unbalanced Quotations in a SAS Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Handling-Unbalanced-Quotations-in-a-SAS-Macro-variable/m-p/533177#M146151</link>
      <description>&lt;P&gt;I would question why you are doing this in macro?&amp;nbsp; A fundamental concept of SAS is the ability to do by group processing.&amp;nbsp; Just put your title in the data itself and then do:&lt;/P&gt;
&lt;PRE&gt;proc print data=...;
  by your_title_variable;
  title '#byval1';
run;&lt;/PRE&gt;
&lt;P&gt;Its really simple.&amp;nbsp; Another method is to call execute from a dataset, avoids all the looping, macro variables etc.&amp;nbsp; Again, simpler coding.&lt;/P&gt;
&lt;P&gt;Provide test data in the form of a datastep and what you want to see out from that for more guidance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 09:49:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Handling-Unbalanced-Quotations-in-a-SAS-Macro-variable/m-p/533177#M146151</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-06T09:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macro: Handling Unbalanced Quotations in a SAS Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Handling-Unbalanced-Quotations-in-a-SAS-Macro-variable/m-p/533178#M146152</link>
      <description>&lt;P&gt;Actually i am using it only in the TITLE statement inside a SAS MACRO, PROC Print I have used to see the Result in the SAS EG. So basically whatever the macro variable holds i have to print it using TITLE statement.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 10:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Handling-Unbalanced-Quotations-in-a-SAS-Macro-variable/m-p/533178#M146152</guid>
      <dc:creator>CC_SAS</dc:creator>
      <dc:date>2019-02-06T10:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Macro: Handling Unbalanced Quotations in a SAS Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Handling-Unbalanced-Quotations-in-a-SAS-Macro-variable/m-p/533179#M146153</link>
      <description>&lt;P&gt;Title statements only have relevance in terms of a procedure which produces output...&lt;/P&gt;
&lt;P&gt;Macro does not produce output, macro does not execute code etc. Macro is a find and replace system.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 10:04:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Handling-Unbalanced-Quotations-in-a-SAS-Macro-variable/m-p/533179#M146153</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-06T10:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro: Handling Unbalanced Quotations in a SAS Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Handling-Unbalanced-Quotations-in-a-SAS-Macro-variable/m-p/533194#M146158</link>
      <description>&lt;P&gt;I got the solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select count(*) into :nrows from data.text;
%put &amp;amp;nrows;
;quit;

%macro test();
%macro d;%mend d;
%do i=1 %to &amp;amp;nrows;
proc sql noprint;
select SRCE_DL_NM into :SRCE_DL_NM from data.text where strip(put(sno,8.))="&amp;amp;i.";
;quit;

%let SRCE_DL = %NRBQUOTE(&amp;amp;SRCE_DL_NM);
proc print data=sashelp.cars(obs=1);
TITLE &amp;amp;SRCE_DL;
RUN;

%end;
%mend();
%test();


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 12:09:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Handling-Unbalanced-Quotations-in-a-SAS-Macro-variable/m-p/533194#M146158</guid>
      <dc:creator>CC_SAS</dc:creator>
      <dc:date>2019-02-06T12:09:20Z</dc:date>
    </item>
  </channel>
</rss>

