<?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 Create Season Variable from Months in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Create-Season-Variable-from-Months/m-p/547428#M8373</link>
    <description>&lt;P&gt;Hi everyone!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to create season variable from months but I get error or I just have Winter or Fall:&lt;/P&gt;&lt;P&gt;I'd appreciate if you'd help me ... Thanks!&lt;/P&gt;&lt;P&gt;data a.hospital1;&lt;BR /&gt;set a.hospital;&lt;BR /&gt;length Season $10;&lt;BR /&gt;if Month in ('March','April','May') then Season='Spring';&lt;BR /&gt;else if Month in ('June','July','August') then Season='Summer';&lt;BR /&gt;else if Month in ('September','October','November') then Season='Fall';&lt;BR /&gt;else Season='Winter';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried this one too:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data a.hospital1;&lt;BR /&gt;set a.hospital;&lt;BR /&gt;length Season $10;&lt;BR /&gt;if (month='January') then season='Winter';&lt;BR /&gt;else if (month='February') then season='Winter';&lt;BR /&gt;else if (month='March') then season='Winter';&lt;BR /&gt;else if (month='April') then season='Spring';&lt;BR /&gt;else if (month='May') then season='Spring';&lt;BR /&gt;else if (month='June') then season='Spring';&lt;BR /&gt;else if (month='July') then season='Summer';&lt;BR /&gt;else if (month='August') then season='Summer';&lt;BR /&gt;else if (month='September') then season='Summer';&lt;BR /&gt;else if (month='October') then season='Fall';&lt;BR /&gt;else if (month='November') then season='Fall';&lt;BR /&gt;else season='Fall';&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Sat, 30 Mar 2019 16:08:11 GMT</pubDate>
    <dc:creator>na_sas</dc:creator>
    <dc:date>2019-03-30T16:08:11Z</dc:date>
    <item>
      <title>Create Season Variable from Months</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-Season-Variable-from-Months/m-p/547428#M8373</link>
      <description>&lt;P&gt;Hi everyone!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to create season variable from months but I get error or I just have Winter or Fall:&lt;/P&gt;&lt;P&gt;I'd appreciate if you'd help me ... Thanks!&lt;/P&gt;&lt;P&gt;data a.hospital1;&lt;BR /&gt;set a.hospital;&lt;BR /&gt;length Season $10;&lt;BR /&gt;if Month in ('March','April','May') then Season='Spring';&lt;BR /&gt;else if Month in ('June','July','August') then Season='Summer';&lt;BR /&gt;else if Month in ('September','October','November') then Season='Fall';&lt;BR /&gt;else Season='Winter';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried this one too:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data a.hospital1;&lt;BR /&gt;set a.hospital;&lt;BR /&gt;length Season $10;&lt;BR /&gt;if (month='January') then season='Winter';&lt;BR /&gt;else if (month='February') then season='Winter';&lt;BR /&gt;else if (month='March') then season='Winter';&lt;BR /&gt;else if (month='April') then season='Spring';&lt;BR /&gt;else if (month='May') then season='Spring';&lt;BR /&gt;else if (month='June') then season='Spring';&lt;BR /&gt;else if (month='July') then season='Summer';&lt;BR /&gt;else if (month='August') then season='Summer';&lt;BR /&gt;else if (month='September') then season='Summer';&lt;BR /&gt;else if (month='October') then season='Fall';&lt;BR /&gt;else if (month='November') then season='Fall';&lt;BR /&gt;else season='Fall';&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Mar 2019 16:08:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-Season-Variable-from-Months/m-p/547428#M8373</guid>
      <dc:creator>na_sas</dc:creator>
      <dc:date>2019-03-30T16:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create Season Variable from Months</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-Season-Variable-from-Months/m-p/547430#M8374</link>
      <description>&lt;UL&gt;
&lt;LI&gt;create a format or&lt;/LI&gt;
&lt;LI&gt;use a&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.3&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p09213s9jc2t99n1vx0omk2rh9ps.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;select&lt;/A&gt;&amp;nbsp;block&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;If you get ERRORs or other problems, post the log, using the {i} button.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Mar 2019 16:13:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-Season-Variable-from-Months/m-p/547430#M8374</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-30T16:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create Season Variable from Months</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-Season-Variable-from-Months/m-p/547431#M8375</link>
      <description>&lt;P&gt;Welcome to the SAS Communities &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a format approach&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format lib=work;
   value $season 'December', 'January', 'February'  = 'Winter'
                 'March', 'April', 'May'            = 'Spring'
                 'June', 'July', 'August'           = 'Summer'
                 'September', 'October', 'November' = 'Fall'
                 other                              = 'N/A'
;
run;

data have;
input Month $20.;
datalines;
January
February
March
April
May
June
July
August
September
October
November
December
NotAMonth
;

data want;
   set have;
   Season=put(Month, $Season.);
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Mar 2019 16:39:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-Season-Variable-from-Months/m-p/547431#M8375</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-03-30T16:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create Season Variable from Months</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-Season-Variable-from-Months/m-p/547432#M8376</link>
      <description>&lt;P&gt;In you first data step, I would not use this line as my last else statement.&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 150%; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;else Season='Winter';&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 150%; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;in your second data step the same thing is happening but you set Season = "Fall";&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 150%; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;if your records have data like "DECEMBER", "Dec", "MARCH", "MAR: they would all be set to Winter.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 150%; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;use the last else statement to catch any data that has errors based on the prior statement.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 150%; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;like this&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 150%; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;else Season = 'Error';&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 150%; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;Does month always have mixed case data?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 150%; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;maybe upcase the test like this&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 150%; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;if upcase(substr(month,1,3)) in ('JAN','FEB',MAR') then Season&amp;nbsp; = "Winter";&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 150%; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;You also have winter defined as containing defernent months in the 2 data steps.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Mar 2019 17:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-Season-Variable-from-Months/m-p/547432#M8376</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-03-30T17:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create Season Variable from Months</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Create-Season-Variable-from-Months/m-p/547541#M8394</link>
      <description>&lt;P&gt;Taking a few precautions should help:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a.hospital1;
set a.hospital;
length Season $10;
select (propcase(month));
    when ('March','April','May') Season='Spring';
    when ('June','July','August') Season='Summer';
    when ('September','October','November') Season='Fall';
    when ('December','January','February') Season='Winter';
    otherwise Season='Error';
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Apr 2019 03:08:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Create-Season-Variable-from-Months/m-p/547541#M8394</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-04-01T03:08:05Z</dc:date>
    </item>
  </channel>
</rss>

