<?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: Create macro vars End and Start dates from YYMM macro var in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-vars-End-and-Start-dates-from-YYMM-macro-var/m-p/753509#M237501</link>
    <description>&lt;P&gt;This question is very close to one of your similar questions from 3 years ago.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Define-the-following-parameter-of-dates-YYMM/m-p/443654#M111016" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Define-the-following-parameter-of-dates-YYMM/m-p/443654#M111016&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Jul 2021 14:43:40 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-07-12T14:43:40Z</dc:date>
    <item>
      <title>Create macro vars End and Start dates from YYMM macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-vars-End-and-Start-dates-from-YYMM-macro-var/m-p/753485#M237491</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;User define&amp;nbsp; a macro variable with structure YYMM (for example: 2107 means month 7 in year 2021).&lt;/P&gt;
&lt;P&gt;From this Macro variable I want to calculate 2 new macro variables: Start and End that will represent start date of month and end date of month.&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;%let YYMM=2107;&lt;/P&gt;
&lt;P&gt;Macro variable called start&amp;nbsp; will get value : '01JUL2021'd&lt;/P&gt;
&lt;P&gt;Macro variable called end&amp;nbsp; will get value : '31JUL2021'd&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the way to calculate macro variables start and End please?&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;</description>
      <pubDate>Mon, 12 Jul 2021 12:29:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-vars-End-and-Start-dates-from-YYMM-macro-var/m-p/753485#M237491</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-07-12T12:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro vars End and Start dates from YYMM macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-vars-End-and-Start-dates-from-YYMM-macro-var/m-p/753500#M237498</link>
      <description>Is this what you need? It assumes the year has to be in 2000s ... the various put statements are just to show what each step does. Also assumes you actually want the date token in the macro variable&lt;BR /&gt;&lt;BR /&gt;%let YYMM=2107;&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;format start end mmddyy10.;&lt;BR /&gt;year = 20 || substr("&amp;amp;yymm",1,2);&lt;BR /&gt;mon = substr("&amp;amp;yymm",3,2);&lt;BR /&gt;put year= ;&lt;BR /&gt;put mon= ;&lt;BR /&gt;&lt;BR /&gt;start = mdy(mon,1,year);&lt;BR /&gt;put start=;&lt;BR /&gt;&lt;BR /&gt;end = intnx('month',start,0,'end');&lt;BR /&gt;put end=;&lt;BR /&gt;&lt;BR /&gt;call symputx('startm',"'"||put(start,date9.)||"'d");&lt;BR /&gt;call symputx('endm',"'"||put(end,date9.)||"'d");&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%put Startm= &amp;amp;startm;&lt;BR /&gt;%put endm= &amp;amp;endm;</description>
      <pubDate>Mon, 12 Jul 2021 13:48:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-vars-End-and-Start-dates-from-YYMM-macro-var/m-p/753500#M237498</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2021-07-12T13:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro vars End and Start dates from YYMM macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-vars-End-and-Start-dates-from-YYMM-macro-var/m-p/753502#M237499</link>
      <description>&lt;P&gt;Do you just need values you can uses in code?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start=%sysfunc(inputn(20&amp;amp;yymm.01,yymmdd8));
%let end=%sysfunc(intnx(month,&amp;amp;start,0,e));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or do you need values that humans will recognize?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start="%sysfunc(inputn(20&amp;amp;yymm.01,yymmdd8),date9)"d;
%let end="%sysfunc(intnx(month,&amp;amp;start,0,e),date9)"d;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;366   %let YYMM=2107;
367   %let start=%sysfunc(inputn(20&amp;amp;yymm.01,yymmdd8));
368   %let end=%sysfunc(intnx(month,&amp;amp;start,0,e));
369   %put &amp;amp;=yymm &amp;amp;=start &amp;amp;=end;
YYMM=2107 START=22462 END=22492
370
371   %let start="%sysfunc(inputn(20&amp;amp;yymm.01,yymmdd8),date9)"d;
372   %let end="%sysfunc(intnx(month,&amp;amp;start,0,e),date9)"d;
373   %put &amp;amp;=yymm &amp;amp;=start &amp;amp;=end;
YYMM=2107 START="01JUL2021"d END="31JUL2021"d
&lt;/PRE&gt;
&lt;P&gt;PS Why are you using only 2 digits for year?&amp;nbsp; I hardcoded the "20" part for the century&amp;nbsp; This will make sure that future dates like 2050 are not translated as 1950 based on your settings for year cutoff.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 13:59:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-vars-End-and-Start-dates-from-YYMM-macro-var/m-p/753502#M237499</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-12T13:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create macro vars End and Start dates from YYMM macro var</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-macro-vars-End-and-Start-dates-from-YYMM-macro-var/m-p/753509#M237501</link>
      <description>&lt;P&gt;This question is very close to one of your similar questions from 3 years ago.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Define-the-following-parameter-of-dates-YYMM/m-p/443654#M111016" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Define-the-following-parameter-of-dates-YYMM/m-p/443654#M111016&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 14:43:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-macro-vars-End-and-Start-dates-from-YYMM-macro-var/m-p/753509#M237501</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-12T14:43:40Z</dc:date>
    </item>
  </channel>
</rss>

