<?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 Adding quotes to a macro created variable. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-a-macro-created-variable/m-p/496170#M131157</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data set where the dates are stored as character&amp;nbsp;so i use a substring to retrieve the data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Where = (substr(CaseCreatedDateTime,1,7) in ("2018-09","2018-08")));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dates need to change each month to the current month and previous month so i'm trying to teach myself to do it in a macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data test;

format Temp_TM Temp_LM DDMMYY10.;
Temp_TM=Today();
Temp_LM=intnx('month',Temp_TM,-1,'b');

month=put(month(Temp_TM),z2.);

ThisMonth1=cat((Year(Temp_TM)),"-",(put(Month(Temp_TM),z2.)));
LastMonth1=cat((Year(Temp_LM)),"-",(put(Month(Temp_LM),z2.)));


run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which gives me two variables with the year and month in in the format above however when i try to reference them sas is seeing it as numeric so it wont work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Where = (substr(CaseCreatedDateTime,1,7) in (&amp;amp;This_Month,&amp;amp;Last_Month);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;i think i need to add quotes around the dates in the macro but am struggling to do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Stret&lt;/P&gt;</description>
    <pubDate>Mon, 17 Sep 2018 10:22:45 GMT</pubDate>
    <dc:creator>Stretlow</dc:creator>
    <dc:date>2018-09-17T10:22:45Z</dc:date>
    <item>
      <title>Adding quotes to a macro created variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-a-macro-created-variable/m-p/496170#M131157</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data set where the dates are stored as character&amp;nbsp;so i use a substring to retrieve the data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Where = (substr(CaseCreatedDateTime,1,7) in ("2018-09","2018-08")));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dates need to change each month to the current month and previous month so i'm trying to teach myself to do it in a macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data test;

format Temp_TM Temp_LM DDMMYY10.;
Temp_TM=Today();
Temp_LM=intnx('month',Temp_TM,-1,'b');

month=put(month(Temp_TM),z2.);

ThisMonth1=cat((Year(Temp_TM)),"-",(put(Month(Temp_TM),z2.)));
LastMonth1=cat((Year(Temp_LM)),"-",(put(Month(Temp_LM),z2.)));


run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which gives me two variables with the year and month in in the format above however when i try to reference them sas is seeing it as numeric so it wont work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Where = (substr(CaseCreatedDateTime,1,7) in (&amp;amp;This_Month,&amp;amp;Last_Month);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;i think i need to add quotes around the dates in the macro but am struggling to do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Stret&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 10:22:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-a-macro-created-variable/m-p/496170#M131157</guid>
      <dc:creator>Stretlow</dc:creator>
      <dc:date>2018-09-17T10:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotes to a macro created variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-a-macro-created-variable/m-p/496173#M131159</link>
      <description>("&amp;amp;This_Month","&amp;amp;Last_Month");</description>
      <pubDate>Mon, 17 Sep 2018 10:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-a-macro-created-variable/m-p/496173#M131159</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-09-17T10:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotes to a macro created variable.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-a-macro-created-variable/m-p/496175#M131161</link>
      <description>&lt;P&gt;jesus i've overthought that just a little haven't i.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 10:41:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-a-macro-created-variable/m-p/496175#M131161</guid>
      <dc:creator>Stretlow</dc:creator>
      <dc:date>2018-09-17T10:41:30Z</dc:date>
    </item>
  </channel>
</rss>

