<?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 Where statement in data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Where-statement-in-data-step/m-p/866587#M342229</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am using a where statement in a data step. My variable runs from '2000' to '2019'. I don't want to write all the years and I believe there may be a way in sas to do it quickly and effectively. All of the values of interest are sequential.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This attempt gave me an error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;where year in ( '2000' --'2019');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Mar 2023 17:52:38 GMT</pubDate>
    <dc:creator>CathyVI</dc:creator>
    <dc:date>2023-03-27T17:52:38Z</dc:date>
    <item>
      <title>Where statement in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-statement-in-data-step/m-p/866587#M342229</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am using a where statement in a data step. My variable runs from '2000' to '2019'. I don't want to write all the years and I believe there may be a way in sas to do it quickly and effectively. All of the values of interest are sequential.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This attempt gave me an error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;where year in ( '2000' --'2019');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 17:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-statement-in-data-step/m-p/866587#M342229</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2023-03-27T17:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Where statement in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-statement-in-data-step/m-p/866592#M342234</link>
      <description>&lt;P&gt;Normally, you would never use a character variable to represent calendar or clock quantities, in this case the year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming you have numeric year values, then this works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
where 2000&amp;lt;=year&amp;lt;=2019;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This also works&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    where year between 2000 and 2019;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Mar 2023 18:01:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-statement-in-data-step/m-p/866592#M342234</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-27T18:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: Where statement in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-statement-in-data-step/m-p/866618#M342251</link>
      <description>&lt;P&gt;If the values are integers you can use : to indicate a sequence.&lt;/P&gt;
&lt;PRE&gt;1    data want;
2      set sashelp.class;
3      where age in (11:13) ;
4    run;

NOTE: There were 10 observations read from the data set SASHELP.CLASS.
      WHERE (age=INT(age)) and (age&amp;gt;=11 and age&amp;lt;=13);
NOTE: The data set WORK.WANT has 10 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.03 seconds
&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Mar 2023 19:40:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-statement-in-data-step/m-p/866618#M342251</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-27T19:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Where statement in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-statement-in-data-step/m-p/866628#M342257</link>
      <description>&lt;P&gt;Since you have quotes, I assume that's a character variable? Convert it to numeric if that's valid and then use BETWEEN.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where input(year, 8.) between 2000 and 2019;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253321"&gt;@CathyVI&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Am using a where statement in a data step. My variable runs from '2000' to '2019'. I don't want to write all the years and I believe there may be a way in sas to do it quickly and effectively. All of the values of interest are sequential.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This attempt gave me an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;where year in ( '2000' --'2019');&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 20:20:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-statement-in-data-step/m-p/866628#M342257</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-03-27T20:20:23Z</dc:date>
    </item>
  </channel>
</rss>

