<?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: How to create macro variables which contains quotes and brackets string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variables-which-contains-quotes-and-brackets/m-p/544288#M150512</link>
    <description>&lt;P&gt;Another option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
    select rule into :var1- from mydatasetname;
quit;
%let nvars=&amp;amp;sqlobs;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You don't even have to know how many &amp;amp;var variables will be created, SAS figures it out for you. The number created is in &amp;amp;SQLOBS, which I have stored for later use in &amp;amp;NVARS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: if the numbers in s_no are not consecutive, this may or may not work, depending on what you do with them. The CALL SYMPUTX method that I provided earlier will work if s_no are not consecutive.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Mar 2019 17:22:29 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-03-19T17:22:29Z</dc:date>
    <item>
      <title>How to create macro variables which contains quotes and brackets string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variables-which-contains-quotes-and-brackets/m-p/544217#M150495</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have following data in rule column:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;s_no&lt;/TD&gt;&lt;TD&gt;rule&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Security_type in("GSEC", "SSEC")&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Security_type = "OAS" AND Guaranteer = "Cent_govt"&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;Security_type = "OAS" AND Guaranteer = "State_govt" AND Residual_maturity LE 0.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;Security_type = "OAS" AND Guaranteer = "State_govt" AND Residual_maturity GT 0.5 LE 2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;Security_type = "OAS" AND Guaranteer = "State_govt" AND Residual_maturity GT 2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create 5 macro variable var1 var2 . . var5 which contains&lt;/P&gt;&lt;P&gt;var1: Security_type in("GSEC", "SSEC")&lt;/P&gt;&lt;P&gt;var2:&amp;nbsp;Security_type = "OAS" AND Guaranteer = "Cent_govt"&amp;nbsp;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sample code is here:&lt;/P&gt;&lt;P&gt;%macro mymacro;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select count(rule) into :count from MRCC_SMM.SMM_report_rules where s_no is not null;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select rule into:var separated by '@' from MRCC_SMM.SMM_report_rules where s_no is not null;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;count;&lt;BR /&gt;data _null_;&lt;BR /&gt;call symput("var&amp;amp;&amp;amp;i.",%sysfunc(scan("&amp;amp;&amp;amp;var.", &amp;amp;&amp;amp;i., "@")));&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%mymacro;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please give any idea how I can do that?. Thanks In advance.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 12:41:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variables-which-contains-quotes-and-brackets/m-p/544217#M150495</guid>
      <dc:creator>Navnath</dc:creator>
      <dc:date>2019-03-19T12:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variables which contains quotes and brackets string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variables-which-contains-quotes-and-brackets/m-p/544218#M150496</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    set have;
    call symputx(cats('var',s_no),rule);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Mar 2019 12:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variables-which-contains-quotes-and-brackets/m-p/544218#M150496</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-19T12:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variables which contains quotes and brackets string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variables-which-contains-quotes-and-brackets/m-p/544220#M150497</link>
      <description>&lt;P&gt;Don't use macro code where you need regular SAS code. Remember macro processor is just there to help you generate SAS code.&amp;nbsp; For this problem you don't need any macro code at all.&amp;nbsp; Just a data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set  MRCC_SMM.SMM_report_rules end=eof;
  where not missing(s_no);
  call symputx(cats('var',_n_),rule);
  if eof then call symputx('count',_n_);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Mar 2019 14:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variables-which-contains-quotes-and-brackets/m-p/544220#M150497</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-03-19T14:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variables which contains quotes and brackets string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variables-which-contains-quotes-and-brackets/m-p/544288#M150512</link>
      <description>&lt;P&gt;Another option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
    select rule into :var1- from mydatasetname;
quit;
%let nvars=&amp;amp;sqlobs;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You don't even have to know how many &amp;amp;var variables will be created, SAS figures it out for you. The number created is in &amp;amp;SQLOBS, which I have stored for later use in &amp;amp;NVARS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: if the numbers in s_no are not consecutive, this may or may not work, depending on what you do with them. The CALL SYMPUTX method that I provided earlier will work if s_no are not consecutive.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 17:22:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variables-which-contains-quotes-and-brackets/m-p/544288#M150512</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-19T17:22:29Z</dc:date>
    </item>
  </channel>
</rss>

