<?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: %let statement with some conditions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/let-statement-with-some-conditions/m-p/562769#M157691</link>
    <description>&lt;P&gt;Replace the two %LET lines into a macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro date(y=, m=);&lt;BR /&gt;%global yyyy mm;
   %if &amp;amp;m = 01 %then %do;
         %let yyyy = %eval(&amp;amp;y - 1);
         %let mm = 12;
    %end; %else %do;
         %let  yyyy = &amp;amp;y;
          %let mm = &amp;amp;m;
%mend date;
%date(y=2018, m=01);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 31 May 2019 04:57:34 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2019-05-31T04:57:34Z</dc:date>
    <item>
      <title>%let statement with some conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-statement-with-some-conditions/m-p/562759#M157684</link>
      <description>&lt;P&gt;Hi all, I&amp;nbsp; want to create a %let statement so that everytime when I run file with&amp;nbsp;the same code I just need to enter the year and&amp;nbsp;date I want.&lt;/P&gt;&lt;P&gt;However, I facing a problem at the last part. my aim is to for ex:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if the month MM=01, my year will be deducted by one&amp;nbsp;and the month will become December instead of January in the set statement like this -&amp;gt;&amp;nbsp;polaclm.pola_clm_&lt;STRONG&gt;agg&lt;/STRONG&gt;_mth_201712&amp;nbsp; and another file I want to combine with this file is &amp;nbsp;polaclm.pola_clm_mth_201801 which is same as the date I set at the beginning.&lt;/P&gt;&lt;P&gt;But for the rest of the month, for ex: YYYY=2018, MM=07, the files name will become like this below&lt;/P&gt;&lt;P&gt;&amp;nbsp;polaclm.pola_clm_&lt;STRONG&gt;agg&lt;/STRONG&gt;_mth_201806 (only the month deducted by 1) and polaclm.pola_clm_mth_201807&amp;nbsp;(same as the number I set at the beginning also)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I put data statement in my if statement because I want to save it as intermediary. however it is not work. Whats wrong with&amp;nbsp; my code below?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; YYYY=2018;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; MM=01;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;libname&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; polaclm C:&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;\Data\POLA\FILE\"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;Data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; polaclm.POLA_clm_mth_&amp;amp;YYYY&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;MM.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;(BODY.......)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;MM.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;01&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;data polaclm.POLA_clm_agg_&amp;amp;YYYY&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;MM.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;polaclm.POLA_clm_agg_(&amp;amp;YYYY-&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;MM.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;polaclm.POLA_clm_mth_&amp;amp;YYYY&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;MM.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;else&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;data polaclm.POLA_clm_agg_&amp;amp;YYYY&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;MM.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;data polaclm.POLA_clm_agg_&amp;amp;YYYY(&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;MM.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;-&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;polaclm.POLA_clm_mth_&amp;amp;YYYY&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;MM.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;　&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;RUN&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jun 2019 01:26:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-statement-with-some-conditions/m-p/562759#M157684</guid>
      <dc:creator>Kayla_Tan222</dc:creator>
      <dc:date>2019-06-01T01:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: %let statement with some conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-statement-with-some-conditions/m-p/562769#M157691</link>
      <description>&lt;P&gt;Replace the two %LET lines into a macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro date(y=, m=);&lt;BR /&gt;%global yyyy mm;
   %if &amp;amp;m = 01 %then %do;
         %let yyyy = %eval(&amp;amp;y - 1);
         %let mm = 12;
    %end; %else %do;
         %let  yyyy = &amp;amp;y;
          %let mm = &amp;amp;m;
%mend date;
%date(y=2018, m=01);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 May 2019 04:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-statement-with-some-conditions/m-p/562769#M157691</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-05-31T04:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: %let statement with some conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-statement-with-some-conditions/m-p/562776#M157697</link>
      <description>&lt;P&gt;Hi Shmuel,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all , Thanks for your reply. Your method is work. However , when I combine the two files I want , the&amp;nbsp; two file chosen is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;pola_clm_agg_mrh_201812 (correct&lt;/STRONG&gt;) and&lt;STRONG&gt; pola_clm_mth_201801 (incorrect, I want&amp;nbsp;201901)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my set statement is below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date(y=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2019&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;, m=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;01&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%global&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;yyyy mm;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;m = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;01&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;yyyy = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;y - 1);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;mm = 12;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;yyyy = &amp;amp;y;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;mm = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;m-1);&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; date;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;date&lt;/I&gt;&lt;/STRONG&gt;(YYYY=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2019&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;, MM=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;01&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; polaclm.pola_clm_agg_&amp;amp;y&amp;amp;m&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;polaclm.pola_clm_agg&lt;STRONG&gt;_&amp;amp;yyyy&amp;amp;mm&lt;/STRONG&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*I want this to be 201812&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;polaclm.pola_clm_mth&lt;STRONG&gt;_&amp;amp;y&amp;amp;m&lt;/STRONG&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;*I Want this to be 201901&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Is there anything wrong?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 06:32:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-statement-with-some-conditions/m-p/562776#M157697</guid>
      <dc:creator>Kayla_Tan222</dc:creator>
      <dc:date>2019-05-31T06:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: %let statement with some conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-statement-with-some-conditions/m-p/562798#M157710</link>
      <description>&lt;P&gt;There are two ways to solve your need:&lt;/P&gt;
&lt;P&gt;1) create 4 macro variables (2019, 01, 2018, 12)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro date(y=, m=);
   %global yyyy mm orgy orgm;  /* org = original value */
   %let orgy = &amp;amp;y;
   %let orgm = &amp;amp;m;
   %if &amp;amp;m = 01 %then %do;
         %let yyyy = %eval(&amp;amp;y - 1);
         %let mm = 12;
    %end; %else %do;
         %let  yyyy = &amp;amp;y;
         %let mm = &amp;amp;m;&lt;BR /&gt;    %end;
%mend date;
%date(y=2019, m=01);

data polaclm.pola_clm_agg_&amp;amp;orgy.&amp;amp;orgm.;
 set polaclm.pola_clm_agg_&amp;amp;yyyy.&amp;amp;mm.         
     polaclm.pola_clm_mth_&amp;amp;orgy.&amp;amp;orgm.; 
 .....
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) or - enter your code into a macro program&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro date(y=, m=);
   %global yyyy mm 
   %let orgm = &amp;amp;m;
   %if &amp;amp;m = 01 %then %do;
         %let yyyy = %eval(&amp;amp;y - 1);
         %let mm = 12;
    %end; %else %do;
         %let  yyyy = &amp;amp;y;
         %let mm = &amp;amp;m;
    %end;
data polaclm.pola_clm_agg_&amp;amp;y.&amp;amp;m.;
 set polaclm.pola_clm_agg_&amp;amp;yyyy.&amp;amp;mm.         
     polaclm.pola_clm_mth_&amp;amp;y.&amp;amp;m.; 
 .....
run; 	
%mend date;
%date(y=2019, m=01);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 May 2019 08:12:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-statement-with-some-conditions/m-p/562798#M157710</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-05-31T08:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: %let statement with some conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/let-statement-with-some-conditions/m-p/562821#M157717</link>
      <description>&lt;P&gt;It is easier to manipulate dates if you turn them into date values.&lt;/P&gt;
&lt;P&gt;Also it does not look like you need separate year and month macro variables.&lt;/P&gt;
&lt;P&gt;So let's just make two macro variables one for the current month and one for the month before.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let current=201801;
%let previous=%sysfunc(intnx(month,%sysfunc(inputn(&amp;amp;current,yymmn6)),-1),yymmn6);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you really need to pull out the year and month values just use %SUBSTR().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pyear=%substr(&amp;amp;previous,1,4);
%let pmonth=%substr(&amp;amp;previous,5,2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2019 12:29:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/let-statement-with-some-conditions/m-p/562821#M157717</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-31T12:29:05Z</dc:date>
    </item>
  </channel>
</rss>

