<?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: Setting ranges of a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Setting-ranges-of-a-variable/m-p/437771#M109078</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;but&amp;nbsp;they didn't do the job.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Your code looks fine so what does 'didn't do the job' mean?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/172057"&gt;@gsk&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have 4 variables of interest: weight, weight unit, height, height unit.&lt;/P&gt;
&lt;P&gt;Weight unit variable has two possible values, pounds or kg.&lt;/P&gt;
&lt;P&gt;Height unit variable has two possible values, inch or cm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to write a code in a data step that does this - how do we write such code i&lt;SPAN&gt;n order to eliminate/print out abnormal values?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;when weight unit is in pound &amp;amp; weight is/is not within a to b&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;when weight unit is in kg &amp;amp; weight is&lt;SPAN&gt;/is not&lt;/SPAN&gt; within c to d&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;when height unit is in inch&lt;SPAN&gt;&amp;nbsp;&amp;amp;&lt;/SPAN&gt; height is&lt;SPAN&gt;/is not&lt;/SPAN&gt; within a2 to b2&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;when height unit is in cm&lt;SPAN&gt;&amp;nbsp;&amp;amp;&lt;/SPAN&gt; height is&lt;SPAN&gt;/is not&lt;/SPAN&gt; within c2 to d2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried a bunch of if/where&amp;nbsp;statements similar to this:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data a;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;set dem;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if not (dema6b = "K" &amp;amp; 30 &amp;lt;=dema6a&amp;lt;=250) or&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; (dema6b = "P" &amp;amp; 66&amp;lt;=dema6a&amp;lt;=550) or&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; (dema6d = "C" &amp;amp; 121&amp;lt;=dema6c&amp;lt;=229) or&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; (dema6d = "I" &amp;amp; 4&amp;lt;=dema6c&amp;lt;=7.5);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but&amp;nbsp;they didn't do the job.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Feb 2018 20:47:16 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-02-15T20:47:16Z</dc:date>
    <item>
      <title>Setting ranges of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Setting-ranges-of-a-variable/m-p/437765#M109075</link>
      <description>&lt;P&gt;I have 4 variables of interest: weight, weight unit, height, height unit.&lt;/P&gt;&lt;P&gt;Weight unit variable has two possible values, pounds or kg.&lt;/P&gt;&lt;P&gt;Height unit variable has two possible values, inch or cm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to write a code in a data step that does this - how do we write such code i&lt;SPAN&gt;n order to eliminate/print out abnormal values?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;when weight unit is in pound &amp;amp; weight is/is not within a to b&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;when weight unit is in kg &amp;amp; weight is&lt;SPAN&gt;/is not&lt;/SPAN&gt; within c to d&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;when height unit is in inch&lt;SPAN&gt;&amp;nbsp;&amp;amp;&lt;/SPAN&gt; height is&lt;SPAN&gt;/is not&lt;/SPAN&gt; within a2 to b2&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;when height unit is in cm&lt;SPAN&gt;&amp;nbsp;&amp;amp;&lt;/SPAN&gt; height is&lt;SPAN&gt;/is not&lt;/SPAN&gt; within c2 to d2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried a bunch of if/where&amp;nbsp;statements similar to this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;set dem;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if not (dema6b = "K" &amp;amp; 30 &amp;lt;=dema6a&amp;lt;=250) or&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; (dema6b = "P" &amp;amp; 66&amp;lt;=dema6a&amp;lt;=550) or&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; (dema6d = "C" &amp;amp; 121&amp;lt;=dema6c&amp;lt;=229) or&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; (dema6d = "I" &amp;amp; 4&amp;lt;=dema6c&amp;lt;=7.5);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but&amp;nbsp;they didn't do the job.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 20:31:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Setting-ranges-of-a-variable/m-p/437765#M109075</guid>
      <dc:creator>gsk</dc:creator>
      <dc:date>2018-02-15T20:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: Setting ranges of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Setting-ranges-of-a-variable/m-p/437771#M109078</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;but&amp;nbsp;they didn't do the job.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Your code looks fine so what does 'didn't do the job' mean?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/172057"&gt;@gsk&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have 4 variables of interest: weight, weight unit, height, height unit.&lt;/P&gt;
&lt;P&gt;Weight unit variable has two possible values, pounds or kg.&lt;/P&gt;
&lt;P&gt;Height unit variable has two possible values, inch or cm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to write a code in a data step that does this - how do we write such code i&lt;SPAN&gt;n order to eliminate/print out abnormal values?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;when weight unit is in pound &amp;amp; weight is/is not within a to b&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;when weight unit is in kg &amp;amp; weight is&lt;SPAN&gt;/is not&lt;/SPAN&gt; within c to d&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;when height unit is in inch&lt;SPAN&gt;&amp;nbsp;&amp;amp;&lt;/SPAN&gt; height is&lt;SPAN&gt;/is not&lt;/SPAN&gt; within a2 to b2&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;when height unit is in cm&lt;SPAN&gt;&amp;nbsp;&amp;amp;&lt;/SPAN&gt; height is&lt;SPAN&gt;/is not&lt;/SPAN&gt; within c2 to d2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried a bunch of if/where&amp;nbsp;statements similar to this:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data a;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;set dem;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if not (dema6b = "K" &amp;amp; 30 &amp;lt;=dema6a&amp;lt;=250) or&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; (dema6b = "P" &amp;amp; 66&amp;lt;=dema6a&amp;lt;=550) or&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; (dema6d = "C" &amp;amp; 121&amp;lt;=dema6c&amp;lt;=229) or&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; (dema6d = "I" &amp;amp; 4&amp;lt;=dema6c&amp;lt;=7.5);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but&amp;nbsp;they didn't do the job.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 20:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Setting-ranges-of-a-variable/m-p/437771#M109078</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-15T20:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Setting ranges of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Setting-ranges-of-a-variable/m-p/437775#M109082</link>
      <description>&lt;P&gt;"Didn't do the job"&amp;nbsp;is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 20:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Setting-ranges-of-a-variable/m-p/437775#M109082</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-15T20:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Setting ranges of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Setting-ranges-of-a-variable/m-p/437787#M109086</link>
      <description>&lt;P&gt;I'm sorry! So with and without the if/where statement, it has same number&amp;nbsp;of observations (1887).&lt;/P&gt;&lt;P&gt;My if/where statements are not doing anything.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here&amp;nbsp;are screenshots of 1) proc print result of the original dataset 2) proc print result of the dataset with the codes I wrote on the question (except that I changed if to where) 3) the log output with the subsetting codes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Original Dataset" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18638i8F2AA2BE7A4AA3B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="dem_data.JPG" alt="Original Dataset" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Original Dataset&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dataset with WHERE statement" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18639iF92FF69557077684/image-size/large?v=v2&amp;amp;px=999" role="button" title="Afterwhere_1887_obs.JPG" alt="Dataset with WHERE statement" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Dataset with WHERE statement&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="the log with WHERE statement" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18640iF7426CC3044545FB/image-size/large?v=v2&amp;amp;px=999" role="button" title="log.JPG" alt="the log with WHERE statement" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;the log with WHERE statement&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 21:01:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Setting-ranges-of-a-variable/m-p/437787#M109086</guid>
      <dc:creator>gsk</dc:creator>
      <dc:date>2018-02-15T21:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Setting ranges of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Setting-ranges-of-a-variable/m-p/437790#M109088</link>
      <description>&lt;P&gt;I think this is the combination you are after:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(dema6b = "K" &amp;amp; not (30 &amp;lt;=dema6a&amp;lt;=250)) or&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; (dema6b = "P" &amp;amp; not (66&amp;lt;=dema6a&amp;lt;=550)) or&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; (dema6d = "C" &amp;amp; not (121&amp;lt;=dema6c&amp;lt;=229)) or&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; (dema6d = "I" &amp;amp; not (4&amp;lt;=dema6c&amp;lt;=7.5)) ;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 21:08:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Setting-ranges-of-a-variable/m-p/437790#M109088</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-15T21:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Setting ranges of a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Setting-ranges-of-a-variable/m-p/437791#M109089</link>
      <description>&lt;P&gt;We can't read that and I'm not even going to try.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change your conditions from subsetting to Flags.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ie create a flag for the first, second and third conditions and run a PROC FREQ on the flags. Or filter on the results by the flag and examine it. It's not a coding issues, your logic is incorrect and we can't debug your logic if we don't know what you want.&amp;nbsp;&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 not (dema6b = "K" and 30 &amp;lt;=dema6a &amp;lt;= 250 ) then flag1=1;
else flag1=0;

run;

data check;
set want;
where flag1=1;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Feb 2018 21:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Setting-ranges-of-a-variable/m-p/437791#M109089</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-15T21:08:14Z</dc:date>
    </item>
  </channel>
</rss>

