<?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: Data step : if (true) output all in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-step-if-true-output-all/m-p/200804#M37512</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Each SET statement can have its own WHERE statement.&amp;nbsp; This approach (untested) should work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if _n_=1 then set have (where=(d_report=&lt;STRONG style="font-family: Courier New; color: #008080; font-size: 10pt;"&gt;'01MAR2015'd&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; and (actual&amp;gt;upper or actual&amp;lt;lower)) );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp; set have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp; where d_report&amp;gt;='01JAN2015'd;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;If the first SET statement retrieves 0 observations, the DATA step will be over.&amp;nbsp; If it does find an observation meeting all 3 conditions, the second SET statement is free to read all observations (subsetting based on its own WHERE statement).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that you are treading on thin ice if you use two-digit years!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Jun 2015 14:43:22 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2015-06-09T14:43:22Z</dc:date>
    <item>
      <title>Data step : if (true) output all</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-if-true-output-all/m-p/200798#M37506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my dataset:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://image.noelshack.com/fichiers/2015/24/1433856711-capture.png" title="http://image.noelshack.com/fichiers/2015/24/1433856711-capture.png"&gt;http://image.noelshack.com/fichiers/2015/24/1433856711-capture.png&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to do something like that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;data forecast2;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; fort_nb01;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; (d_report=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-family: Courier New; font-size: 10pt;"&gt;'01MAR15'd&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; and&amp;nbsp; (actual&amp;gt;upper or actual&amp;lt;lower)) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; output fort_nb01(where d_report&amp;gt;='01JAN15'd)&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;Of course it doesn't work but I tried thousands ways to do that (dubble if, if/where, select,...) and, when it works, I always can have only the row with '01MAR15'd but I would like (if this condition is true) rows from '01JAN15' to the end.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;This problem seems very easy but I still have not found a solution.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;Thanks for your help!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 13:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-if-true-output-all/m-p/200798#M37506</guid>
      <dc:creator>problems99</dc:creator>
      <dc:date>2015-06-09T13:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Data step : if (true) output all</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-if-true-output-all/m-p/200799#M37507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Its a good idea to post test data in the form of a datatep and required output.&amp;nbsp; At a guess:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table WANT as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (select * from HAVE where DATE &amp;gt;= "01JAN15"d)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID in (select distinct ID from HAVE where ACTUAL &amp;gt; UPPER or ACTUAL &amp;lt; LOWER);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 13:53:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-if-true-output-all/m-p/200799#M37507</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-06-09T13:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: Data step : if (true) output all</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-if-true-output-all/m-p/200800#M37508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks but it is not really what I want. I was not clear, sorry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like something like that : (I know it is totally impossible in SQl but it is to show the idea)&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;&lt;SPAN style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;&lt;SPAN style="color: #575757;"&gt;proc &lt;/SPAN&gt;&lt;STRONG&gt;sql&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;create&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; WANT &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;as&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #ff0000; font-size: 10pt; font-family: Courier New;"&gt;if (date='01MAR15'd and ACTUAL &amp;gt; UPPER or ACTUAL &amp;lt; LOWER) then {&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; * &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp; (&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; * &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; HAVE &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 10pt; font-family: Courier New;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; date &amp;gt;= &lt;/SPAN&gt;&lt;SPAN style="; color: #008080; font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;"01JAN15"d&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;quit&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;I check only the condition for March. If true, I create a new table with the rows from JAN to the end anyway the result of the condition for these months.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 14:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-if-true-output-all/m-p/200800#M37508</guid>
      <dc:creator>problems99</dc:creator>
      <dc:date>2015-06-09T14:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Data step : if (true) output all</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-if-true-output-all/m-p/200801#M37509</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Still the same code, your just thinking about the problem in the other way round.&amp;nbsp; &lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc sql;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table WANT as&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (select * from HAVE where DATE &amp;gt;= "01JAN15"d)&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;/* So take all data from original dataset with a date after 01JAN15 *.&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID in (select distinct ID from HAVE where (DATE="01MAR15"d and (ACTUAL &amp;gt; UPPER or ACTUAL &amp;lt; LOWER));&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;/* But restrict the main dataset to those ID's having on the Mar, actual outside the bounds */&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 14:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-if-true-output-all/m-p/200801#M37509</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-06-09T14:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Data step : if (true) output all</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-if-true-output-all/m-p/200802#M37510</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stupid question but what is ID in my case?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 14:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-if-true-output-all/m-p/200802#M37510</guid>
      <dc:creator>problems99</dc:creator>
      <dc:date>2015-06-09T14:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Data step : if (true) output all</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-if-true-output-all/m-p/200803#M37511</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Some identifier in you data, e.g.&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ACTUAL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UPPER&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOWER&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ....&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 14:34:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-if-true-output-all/m-p/200803#M37511</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-06-09T14:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Data step : if (true) output all</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-if-true-output-all/m-p/200804#M37512</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Each SET statement can have its own WHERE statement.&amp;nbsp; This approach (untested) should work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if _n_=1 then set have (where=(d_report=&lt;STRONG style="font-family: Courier New; color: #008080; font-size: 10pt;"&gt;'01MAR2015'd&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; and (actual&amp;gt;upper or actual&amp;lt;lower)) );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp; set have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp; where d_report&amp;gt;='01JAN2015'd;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;If the first SET statement retrieves 0 observations, the DATA step will be over.&amp;nbsp; If it does find an observation meeting all 3 conditions, the second SET statement is free to read all observations (subsetting based on its own WHERE statement).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that you are treading on thin ice if you use two-digit years!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 14:43:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-if-true-output-all/m-p/200804#M37512</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-06-09T14:43:22Z</dc:date>
    </item>
  </channel>
</rss>

