<?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: selecting observations that fall on a certain decimal place in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/486969#M126800</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4877"&gt;@Haikuo&lt;/a&gt;&amp;nbsp;has given you the right solution.&amp;nbsp; I just wanted to clarify some of the rules.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WHERE requires that the variables you refer to are part of the incoming data set.&amp;nbsp; In your original program, VAR exists, but I does not (not as part of the incoming data set, anyway).&amp;nbsp; So a WHERE statement can refer to VAR but not to I.&amp;nbsp; That's why your program generates an error.&amp;nbsp; In&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4877"&gt;@Haikuo&lt;/a&gt;'s solution, since VAR already exists, you should be able to change IF to WHERE.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Aug 2018 12:46:30 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-08-15T12:46:30Z</dc:date>
    <item>
      <title>selecting observations that fall on a certain decimal place</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/486873#M126747</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to select only observations that fall on the tenth, as opposed to hundredth decimal place (e.g. 1.10, 1.20, 1.30 vs. 1.11, 1.12, 1.13). The variable goes from one to five.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried:&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;do i=1 to 5 by .1;&lt;/P&gt;&lt;P&gt;where var=i;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I receive an error that i is not on file in my data set. Does anyone know why/a different approach?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Emily&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 23:19:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/486873#M126747</guid>
      <dc:creator>Caetreviop543</dc:creator>
      <dc:date>2018-08-14T23:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: selecting observations that fall on a certain decimal place</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/486880#M126752</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
do i=1 to 5 by 0.1;
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Can you try this? I hope it helps.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 01:28:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/486880#M126752</guid>
      <dc:creator>shahparth260</dc:creator>
      <dc:date>2018-08-15T01:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: selecting observations that fall on a certain decimal place</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/486884#M126753</link>
      <description>&lt;P&gt;You could do a similar approach by using 'if' instead of 'where' plus some to achieve your goal, but it is neither efficient (in your example you need to check 40 numbers for one) nor robust (how do you know 1 to 5 will cover it?). Here is an alternative:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
if mod(var,0.1)=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can't use 'where' in this case, as 'where' process data before loading into the PDV, aka, compile stage.&amp;nbsp; in your case, you need to process data during run-time stage.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 02:30:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/486884#M126753</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2018-08-15T02:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: selecting observations that fall on a certain decimal place</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/486969#M126800</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4877"&gt;@Haikuo&lt;/a&gt;&amp;nbsp;has given you the right solution.&amp;nbsp; I just wanted to clarify some of the rules.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WHERE requires that the variables you refer to are part of the incoming data set.&amp;nbsp; In your original program, VAR exists, but I does not (not as part of the incoming data set, anyway).&amp;nbsp; So a WHERE statement can refer to VAR but not to I.&amp;nbsp; That's why your program generates an error.&amp;nbsp; In&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4877"&gt;@Haikuo&lt;/a&gt;'s solution, since VAR already exists, you should be able to change IF to WHERE.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 12:46:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/486969#M126800</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-08-15T12:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: selecting observations that fall on a certain decimal place</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/486978#M126805</link>
      <description>&lt;P&gt;Thanks for clarification, Robert. Looking back to my post, one can easily be confused, especially when I used 'if'. &amp;nbsp;I am not editing it since we already have your post.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 13:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/486978#M126805</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2018-08-15T13:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: selecting observations that fall on a certain decimal place</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/487066#M126839</link>
      <description>&lt;P&gt;Hi Emily,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You were actually lucky that SAS didn't accept your code due to the inappropriate WHERE statement. If you had used syntactically correct code such as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if var=i then output;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;your selection would most likely have been incorrect: The risk of &lt;EM&gt;not&lt;/EM&gt; selecting numbers like 1.2 or 2.5 (which meet your selection criterion) would have been very high because of &lt;EM&gt;numeric representation issues&lt;/EM&gt;. A 0.1 increment in a DO loop is one of the standard examples of how numeric representation errors can accumulate to rounding errors which invalidate equations like &lt;FONT face="courier new,courier"&gt;var=i&lt;/FONT&gt;&amp;nbsp;(see &lt;A href="https://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=p0ji1unv6thm0dn1gp4t01a1u0g6.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n1x2otl5a3i0win1jc0yjo323fsj" target="_blank"&gt;documentation&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4877"&gt;@Haikuo&lt;/a&gt;'s solution is much better in this regard too. To quote the documentation: "The MOD function performs extra computations, called fuzzing, to return an exact zero when the result would otherwise differ from zero because of numerical error."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on how you obtained the values of &lt;FONT face="courier new,courier"&gt;var&lt;/FONT&gt;, it could still make sense to use (slightly) rounded values in selection criteria, e.g.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;round(var, 1e-9)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 16:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/487066#M126839</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-08-15T16:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: selecting observations that fall on a certain decimal place</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/487173#M126907</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did try this, but it only gives me one column, i, from 1 to 5 by .1. I need the new data set to retain variables from my previous data set, which is why I used a set statement in the original code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that make sense? Thanks for your help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 20:13:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/487173#M126907</guid>
      <dc:creator>Caetreviop543</dc:creator>
      <dc:date>2018-08-15T20:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: selecting observations that fall on a certain decimal place</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/487179#M126910</link>
      <description>&lt;P&gt;Thanks! I'm not familiar with the mod function, but that worked.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 20:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-observations-that-fall-on-a-certain-decimal-place/m-p/487179#M126910</guid>
      <dc:creator>Caetreviop543</dc:creator>
      <dc:date>2018-08-15T20:20:22Z</dc:date>
    </item>
  </channel>
</rss>

