<?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 IF THEN date, SAS read some but not all my data points in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-date-SAS-read-some-but-not-all-my-data-points/m-p/493306#M129760</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm very much a beginner in SAS (version 9.3), so I'm trying to handle my data the easiest way possible. I'm trying to create seasons for my data that has dates over 5 years (I have 94230 obs). First I created a column with months and then an IF THEN statement, but it only returns an empty column. So, instead I took the really loong way of doing it and went thru all my dates and created a new IF THEN statement. Now SAS reads all the dates and turn them in to seasons, except for my last row, where it only reads the first date, turn that into the right season (date 20728 to season 3), but stops reading the following dates. What to do?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First I tried this, the month column is alright but the season didn't work&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; sintid2;&lt;/P&gt;&lt;P&gt;set sintid1;&lt;/P&gt;&lt;P&gt;month=kalvdat;&lt;BR /&gt;format month month.;&lt;/P&gt;&lt;P&gt;if &lt;STRONG&gt;1&lt;/STRONG&gt;&amp;gt;= month=&amp;lt;&lt;STRONG&gt;4&lt;/STRONG&gt; then season=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;if &lt;STRONG&gt;5&lt;/STRONG&gt;&amp;gt;= month=&amp;lt;&lt;STRONG&gt;9&lt;/STRONG&gt; then season=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;if &lt;STRONG&gt;10&lt;/STRONG&gt;&amp;gt;= month=&amp;lt;&lt;STRONG&gt;12&lt;/STRONG&gt; then season=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I did this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; sintid2;&lt;/P&gt;&lt;P&gt;set sintid1;&lt;/P&gt;&lt;P&gt;if &lt;STRONG&gt;18993&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19113&lt;/STRONG&gt; then season=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19114&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19266&lt;/STRONG&gt; then season=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19267&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19358&lt;/STRONG&gt; then season=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19359&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19478&lt;/STRONG&gt; then season=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19479&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19631&lt;/STRONG&gt; then season=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19632&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19723&lt;/STRONG&gt; then season=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19724&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19843&lt;/STRONG&gt; then season=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19844&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19996&lt;/STRONG&gt; then season=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19997&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;20088&lt;/STRONG&gt; then season=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;20089&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;20208&lt;/STRONG&gt; then season=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;20209&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;20361&lt;/STRONG&gt; then season=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;20362&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;20453&lt;/STRONG&gt; then season=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;20454&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;20574&lt;/STRONG&gt; then season=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;20575&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;20727&lt;/STRONG&gt; then season=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;20728&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;20819&lt;/STRONG&gt; then season=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And as explained, it returns season for all rows except the last row (stops after 20728).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried this for the last row&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;else if kalvdat=&amp;lt;&lt;STRONG&gt;20728&lt;/STRONG&gt; then season=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But then, another strange thing happends: then the row above 20575-20727 doesn't work, but all days in the last row (day 20728-20819) get season 3.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I assume I am missing out on some small command, but which?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;Lisa&lt;/P&gt;</description>
    <pubDate>Fri, 07 Sep 2018 08:26:50 GMT</pubDate>
    <dc:creator>Lisan</dc:creator>
    <dc:date>2018-09-07T08:26:50Z</dc:date>
    <item>
      <title>IF THEN date, SAS read some but not all my data points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-date-SAS-read-some-but-not-all-my-data-points/m-p/493306#M129760</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm very much a beginner in SAS (version 9.3), so I'm trying to handle my data the easiest way possible. I'm trying to create seasons for my data that has dates over 5 years (I have 94230 obs). First I created a column with months and then an IF THEN statement, but it only returns an empty column. So, instead I took the really loong way of doing it and went thru all my dates and created a new IF THEN statement. Now SAS reads all the dates and turn them in to seasons, except for my last row, where it only reads the first date, turn that into the right season (date 20728 to season 3), but stops reading the following dates. What to do?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First I tried this, the month column is alright but the season didn't work&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; sintid2;&lt;/P&gt;&lt;P&gt;set sintid1;&lt;/P&gt;&lt;P&gt;month=kalvdat;&lt;BR /&gt;format month month.;&lt;/P&gt;&lt;P&gt;if &lt;STRONG&gt;1&lt;/STRONG&gt;&amp;gt;= month=&amp;lt;&lt;STRONG&gt;4&lt;/STRONG&gt; then season=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;if &lt;STRONG&gt;5&lt;/STRONG&gt;&amp;gt;= month=&amp;lt;&lt;STRONG&gt;9&lt;/STRONG&gt; then season=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;if &lt;STRONG&gt;10&lt;/STRONG&gt;&amp;gt;= month=&amp;lt;&lt;STRONG&gt;12&lt;/STRONG&gt; then season=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I did this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; sintid2;&lt;/P&gt;&lt;P&gt;set sintid1;&lt;/P&gt;&lt;P&gt;if &lt;STRONG&gt;18993&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19113&lt;/STRONG&gt; then season=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19114&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19266&lt;/STRONG&gt; then season=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19267&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19358&lt;/STRONG&gt; then season=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19359&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19478&lt;/STRONG&gt; then season=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19479&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19631&lt;/STRONG&gt; then season=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19632&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19723&lt;/STRONG&gt; then season=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19724&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19843&lt;/STRONG&gt; then season=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19844&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;19996&lt;/STRONG&gt; then season=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;19997&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;20088&lt;/STRONG&gt; then season=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;20089&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;20208&lt;/STRONG&gt; then season=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;20209&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;20361&lt;/STRONG&gt; then season=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;20362&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;20453&lt;/STRONG&gt; then season=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;20454&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;20574&lt;/STRONG&gt; then season=&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;20575&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;20727&lt;/STRONG&gt; then season=&lt;STRONG&gt;2&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;else if &lt;STRONG&gt;20728&lt;/STRONG&gt;&amp;gt;= kalvdat=&amp;lt;&lt;STRONG&gt;20819&lt;/STRONG&gt; then season=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And as explained, it returns season for all rows except the last row (stops after 20728).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried this for the last row&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;else if kalvdat=&amp;lt;&lt;STRONG&gt;20728&lt;/STRONG&gt; then season=&lt;STRONG&gt;3&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But then, another strange thing happends: then the row above 20575-20727 doesn't work, but all days in the last row (day 20728-20819) get season 3.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I assume I am missing out on some small command, but which?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;Lisa&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 08:26:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-date-SAS-read-some-but-not-all-my-data-points/m-p/493306#M129760</guid>
      <dc:creator>Lisan</dc:creator>
      <dc:date>2018-09-07T08:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN date, SAS read some but not all my data points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-date-SAS-read-some-but-not-all-my-data-points/m-p/493308#M129762</link>
      <description>&lt;P&gt;What you are missing is that the format does not change the actual value of a variable, only how it is displayed.&lt;/P&gt;&lt;P&gt;What you want to do is probably something like this (using the month function instead):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sintid2;
  set sintid1;
  month=month(kalvdat);&lt;BR /&gt;  if month&amp;gt;=10 then 
    season=3;
  else if month&amp;gt;=5 then 
    season=2;
  else if not missing(month) then  
    season=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Sep 2018 08:39:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-date-SAS-read-some-but-not-all-my-data-points/m-p/493308#M129762</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-09-07T08:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN date, SAS read some but not all my data points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-date-SAS-read-some-but-not-all-my-data-points/m-p/493312#M129765</link>
      <description>&lt;P&gt;Out of interest, why is there only 3 seasons?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 08:57:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-date-SAS-read-some-but-not-all-my-data-points/m-p/493312#M129765</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-07T08:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN date, SAS read some but not all my data points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-date-SAS-read-some-but-not-all-my-data-points/m-p/493315#M129767</link>
      <description>&lt;P&gt;Thank you so much! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 09:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-date-SAS-read-some-but-not-all-my-data-points/m-p/493315#M129767</guid>
      <dc:creator>Lisan</dc:creator>
      <dc:date>2018-09-07T09:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN date, SAS read some but not all my data points</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-THEN-date-SAS-read-some-but-not-all-my-data-points/m-p/493316#M129768</link>
      <description>1= indoor season, winter feed&lt;BR /&gt;2=outdoor season, pasture&lt;BR /&gt;3=indoor season, fall feed&lt;BR /&gt;</description>
      <pubDate>Fri, 07 Sep 2018 09:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-THEN-date-SAS-read-some-but-not-all-my-data-points/m-p/493316#M129768</guid>
      <dc:creator>Lisan</dc:creator>
      <dc:date>2018-09-07T09:09:38Z</dc:date>
    </item>
  </channel>
</rss>

