<?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: Extracting month error in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-error/m-p/783969#M32038</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/335985"&gt;@Barkat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I would like to get Jan2021&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The format DTMONYY. on your date/time variable should get you there. No need to create additional variables .&lt;/P&gt;</description>
    <pubDate>Fri, 03 Dec 2021 17:25:19 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-12-03T17:25:19Z</dc:date>
    <item>
      <title>Extracting month error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-error/m-p/783958#M32032</link>
      <description>&lt;P&gt;I was trying to extract month using the following statements but all months display as Jan1960.&lt;/P&gt;
&lt;P&gt;Month=month(Datepart(AdmitDate));&lt;BR /&gt;Format Month MONYY7.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FYI:&amp;nbsp;AdmitDate is a datetime variable. When I extract only date from&amp;nbsp;AdmitDate using&amp;nbsp;Datepart(AdmitDate), it works completely fine.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 16:45:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-month-error/m-p/783958#M32032</guid>
      <dc:creator>Barkat</dc:creator>
      <dc:date>2021-12-03T16:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-error/m-p/783960#M32034</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Month=month(Datepart(AdmitDate));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Format Month MONYY7.;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The MONTH() function returns a number from 1 to 12, and so variable MONTH is a number from 1 to 12. So when you format the value of Month as MONYY7, the results will indeed be JAN1960. So what are you really trying to do? What is the desired output?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Does formatting AdmitDate as DTMONYY7. do what you want?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 17:03:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-month-error/m-p/783960#M32034</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-03T17:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-error/m-p/783961#M32035</link>
      <description>&lt;P&gt;You don't need to pull the month out of the date value, just format the datepart. See example below, note I used admitDateTime to store the datetime value and admitDate to store the date value. Whereas your code uses admitDate and month.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;2362  data _null_ ;
2363      admitDateTime=datetime() ;
2364      admitDate=datepart(admitDateTime) ;
2365      format admitDate monyy7. ;
2366      put admitDateTime= admitDate= ;
2367  run ;

admitDateTime=1954152114.8 admitDate=DEC2021
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 17:03:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-month-error/m-p/783961#M32035</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-12-03T17:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-error/m-p/783962#M32036</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226241"&gt;@AMSAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You don't need to pull the month out of the date value, just format the datepart. See example below, note I used admitDateTime to store the datetime value and admitDate to store the date value. Whereas your code uses admitDate and month.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You don't even need a new variable. Use format DTMONYY7. on the date/time variable.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 17:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-month-error/m-p/783962#M32036</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-03T17:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-error/m-p/783965#M32037</link>
      <description>I would like to get Jan2021</description>
      <pubDate>Fri, 03 Dec 2021 17:17:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-month-error/m-p/783965#M32037</guid>
      <dc:creator>Barkat</dc:creator>
      <dc:date>2021-12-03T17:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-error/m-p/783969#M32038</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/335985"&gt;@Barkat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I would like to get Jan2021&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The format DTMONYY. on your date/time variable should get you there. No need to create additional variables .&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 17:25:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-month-error/m-p/783969#M32038</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-03T17:25:19Z</dc:date>
    </item>
  </channel>
</rss>

