<?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/day from dates in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/532240#M6002</link>
    <description>&lt;P&gt;Good to hear&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/221595"&gt;@AMMAN&lt;/a&gt;&amp;nbsp;I'd encourage you to pick and solution and mark it as accepted. It helps others when searching/filtering through posts.&lt;/P&gt;</description>
    <pubDate>Sat, 02 Feb 2019 00:52:46 GMT</pubDate>
    <dc:creator>ChrisBrooks</dc:creator>
    <dc:date>2019-02-02T00:52:46Z</dc:date>
    <item>
      <title>Extracting month/day from dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/531844#M5930</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data month;
set work.student_roster;
length justmonth $15;
justmonth = scan(birth_day, 2, 3);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I need to extract the month from a field formatted as a date9.&amp;nbsp; For example, if the value is 31Jan1999, I need to extract "Jan" as a new variable.&amp;nbsp;&amp;nbsp; I'm using the scan function but I'm getting weird results:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="weird.JPG" style="width: 107px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26747iBBE0EC6A80BEC8E9/image-size/large?v=v2&amp;amp;px=999" role="button" title="weird.JPG" alt="weird.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I think this is because of the format.&amp;nbsp; I need to reformat this variable into a string?&amp;nbsp;&amp;nbsp; If that's correct, can you please suggest the best way to go about it?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 00:03:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/531844#M5930</guid>
      <dc:creator>AMMAN</dc:creator>
      <dc:date>2019-02-01T00:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month/day from dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/531850#M5931</link>
      <description>&lt;P&gt;If you have a SAS date, which is a variable that's numeric with a date format then you have a number and SCAN() will not work on a number. You can convert it to a character or you can use formats to get your desired output.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;

format date date9.;

do date='01Jan2018'd to '31Dec2018'd by 30;
    month = put(date, monname3.);
    day = day(date);
    output;
end;

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/221595"&gt;@AMMAN&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data month;
set work.student_roster;
length justmonth $15;
justmonth = scan(birth_day, 2, 3);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I need to extract the month from a field formatted as a date9.&amp;nbsp; For example, if the value is 31Jan1999, I need to extract "Jan" as a new variable.&amp;nbsp;&amp;nbsp; I'm using the scan function but I'm getting weird results:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="weird.JPG" style="width: 107px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26747iBBE0EC6A80BEC8E9/image-size/large?v=v2&amp;amp;px=999" role="button" title="weird.JPG" alt="weird.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I think this is because of the format.&amp;nbsp; I need to reformat this variable into a string?&amp;nbsp;&amp;nbsp; If that's correct, can you please suggest the best way to go about it?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 00:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/531850#M5931</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-01T00:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month/day from dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/531851#M5932</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/221595"&gt;@AMMAN&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually the dates in your attachment aren't formatted as date9 but as mmddyy9 but the same solution should work either way. You can use a put statement with the monnmae format as shown below (I've used the first three records from your attachment&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	infile datalines dlm=",";
	length name $5 bday 8;
	informat bday mmddyy9.;
	format bday mmddyy9.;
	input name bday;
datalines;
Chas,5/15/1986
Pearl,3/6/1997
Troy,3/26/1999
;
run;

data want;
	set have;
	justmonth=substr(strip(put(bday, monname.)),1,3);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Feb 2019 01:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/531851#M5932</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2019-02-01T01:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month/day from dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/532057#M5971</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32246"&gt;@ChrisBrooks&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/221595"&gt;@AMMAN&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually the dates in your attachment aren't formatted as date9 but as mmddyy9 but the same solution should work either way. You can use a put statement with the monnmae format as shown below (I've used the first three records from your attachment&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32246"&gt;@ChrisBrooks&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why not&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;justmonth= put(bday, &lt;/FONT&gt;&lt;FONT color="#804040" face="SAS Monospace" size="2"&gt;monname3.&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 15:54:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/532057#M5971</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-01T15:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month/day from dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/532164#M5985</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 19:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/532164#M5985</guid>
      <dc:creator>AMMAN</dc:creator>
      <dc:date>2019-02-01T19:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month/day from dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/532165#M5986</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp; This worked!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 19:21:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/532165#M5986</guid>
      <dc:creator>AMMAN</dc:creator>
      <dc:date>2019-02-01T19:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month/day from dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/532166#M5987</link>
      <description>&lt;P&gt;Thank you.&amp;nbsp; This worked.&amp;nbsp; In fact, I tried all the recommendations and they worked!&amp;nbsp; I'm not sure how to mark "solution" in this case.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 19:21:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/532166#M5987</guid>
      <dc:creator>AMMAN</dc:creator>
      <dc:date>2019-02-01T19:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month/day from dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/532238#M6001</link>
      <description>&lt;P&gt;Good point&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;that's more succinct!&lt;/P&gt;</description>
      <pubDate>Sat, 02 Feb 2019 00:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/532238#M6001</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2019-02-02T00:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting month/day from dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/532240#M6002</link>
      <description>&lt;P&gt;Good to hear&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/221595"&gt;@AMMAN&lt;/a&gt;&amp;nbsp;I'd encourage you to pick and solution and mark it as accepted. It helps others when searching/filtering through posts.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Feb 2019 00:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-month-day-from-dates/m-p/532240#M6002</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2019-02-02T00:52:46Z</dc:date>
    </item>
  </channel>
</rss>

