<?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 extract month from data in PROC SQL? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-month-from-data-in-PROC-SQL/m-p/775766#M246620</link>
    <description>&lt;P&gt;Depending on what you are doing if you have an actual date value you may not need a new variable. SAS formatted values are honored by reporting and most graphing and analysis procedures. Possibly just using the YEAR4. format in the step you want to use the data will work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;</description>
    <pubDate>Thu, 21 Oct 2021 21:24:17 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-10-21T21:24:17Z</dc:date>
    <item>
      <title>How to extract month from data in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-month-from-data-in-PROC-SQL/m-p/775747#M246601</link>
      <description>&lt;P&gt;Hi, I am trying to extract only the months from these dates in a new column labelled as "Month" in PROC SQL.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2021-10-21 at 4.30.24 PM.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64940i334971F2DBAA234E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2021-10-21 at 4.30.24 PM.png" alt="Screen Shot 2021-10-21 at 4.30.24 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone please help me?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 20:31:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-month-from-data-in-PROC-SQL/m-p/775747#M246601</guid>
      <dc:creator>rliu0712</dc:creator>
      <dc:date>2021-10-21T20:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract month from data in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-month-from-data-in-PROC-SQL/m-p/775749#M246603</link>
      <description>Is it a numeric or character column?&lt;BR /&gt;&lt;BR /&gt;If it's numeric with a date format use the MONTH() function, if it's character use SCAN()&lt;BR /&gt;&lt;BR /&gt;E.G. select month(dateVariable) as monthNum, scan(month, 2, "-") as monthChar</description>
      <pubDate>Thu, 21 Oct 2021 20:33:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-month-from-data-in-PROC-SQL/m-p/775749#M246603</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-21T20:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract month from data in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-month-from-data-in-PROC-SQL/m-p/775751#M246605</link>
      <description>&lt;P&gt;it is in "2020-03-21" format..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;month(dateVariable) as monthNum --&amp;gt; do I replace "dateVariable" with my column name?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 20:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-month-from-data-in-PROC-SQL/m-p/775751#M246605</guid>
      <dc:creator>rliu0712</dc:creator>
      <dc:date>2021-10-21T20:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract month from data in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-month-from-data-in-PROC-SQL/m-p/775755#M246609</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/400731"&gt;@rliu0712&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;it is in "2020-03-21" format..&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SAS has variable types and formats.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Types can be numeric or character and formats control how a variable is displayed. Your answer doesn't answer the question asked - is your variable numeric or character. Either can appear as you've shown but how they're stored can differ.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
dateCharacter = "2020-03-21";
date_numeric = "21Mar2020"d;
format date_numeric yymmddd10.;
run;

title 'Can you tell the difference between numeric and character dates?';
proc print data=demo;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/400731"&gt;@rliu0712&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;month(dateVariable) as monthNum --&amp;gt; do I replace "dateVariable" with my column name?&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, replace it with your variable name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 20:59:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-month-from-data-in-PROC-SQL/m-p/775755#M246609</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-21T20:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract month from data in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-month-from-data-in-PROC-SQL/m-p/775765#M246619</link>
      <description>&lt;P&gt;Yes, I just figured out it is numeric with format YYMMDD10.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;the "select month(dateVariable) as monthNum from table" does not seem to work..&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 21:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-month-from-data-in-PROC-SQL/m-p/775765#M246619</guid>
      <dc:creator>rliu0712</dc:creator>
      <dc:date>2021-10-21T21:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract month from data in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-month-from-data-in-PROC-SQL/m-p/775766#M246620</link>
      <description>&lt;P&gt;Depending on what you are doing if you have an actual date value you may not need a new variable. SAS formatted values are honored by reporting and most graphing and analysis procedures. Possibly just using the YEAR4. format in the step you want to use the data will work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 21:24:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-month-from-data-in-PROC-SQL/m-p/775766#M246620</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-21T21:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract month from data in PROC SQL?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-month-from-data-in-PROC-SQL/m-p/775767#M246621</link>
      <description>Define not work. &lt;BR /&gt;What are you trying to do overall that isn't working?&lt;BR /&gt;Show your code and log please.</description>
      <pubDate>Thu, 21 Oct 2021 21:24:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-month-from-data-in-PROC-SQL/m-p/775767#M246621</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-21T21:24:22Z</dc:date>
    </item>
  </channel>
</rss>

