<?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: Resolve Conditions in a datastep in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764488#M242159</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/179936"&gt;@arpitsharma27&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Obviously I put a template here. Once I get the idea of how code works, I can use it.&lt;/P&gt;
&lt;P&gt;Anyways, I think I figured out&amp;nbsp; using &lt;STRONG&gt;dosubl&lt;/STRONG&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A big caution with simple templates. If they are too simple then you are implying the actual process is less complicated than it actually is. For example, if your real problem involves multiple different comparisons then you should provide examples of those as well.&lt;/P&gt;
&lt;P&gt;Reasons: Your initial post would be much better of just placing the EXACT SAME comparisons into to code. No need to dirty up code for a the same comparison will all values.&lt;/P&gt;
&lt;P&gt;The approaches provided that involve 2 comparisons may not work as expected if there is only one comparison. This is quite likely in the case of only having an Upper comparison that involves &amp;lt; in any form and a missing value. since MISSING is lest than anything. Note: you did not state that the value is never missing. Considerations for that may need to be applied.&lt;/P&gt;
&lt;P&gt;And what happens if you throw in a third comparison? Or another value?&lt;/P&gt;
&lt;P&gt;Providing essentially one use case for the comparison boundaries is quite likely to lead to code that is not quite what is needed.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Aug 2021 15:59:21 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-08-27T15:59:21Z</dc:date>
    <item>
      <title>Resolve Conditions in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764346#M242098</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input value lower :$10. upper :$10.;
infile datalines dlm=",";
datalines;
0.0035,&amp;gt;=0.0035,&amp;lt;=0.034
0.034,&amp;gt;=0.0035,&amp;lt;=0.034
0.0045,&amp;gt;=0.0035,&amp;lt;=0.034
;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Within a Datastep(not _NULL_), I want to evaluate the condition&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;value||lower/*value &amp;gt;=0.0035*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;value||upper/*value &amp;lt;=0.034*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and if the conditions are met then create another variable- flag with value "GOOD" else value should be "BAD".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please advise.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 21:01:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764346#M242098</guid>
      <dc:creator>arpitsharma27</dc:creator>
      <dc:date>2021-08-26T21:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve Conditions in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764350#M242102</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/179936"&gt;@arpitsharma27&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;I have this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input value lower :$10. upper :$10.;
infile datalines dlm=",";
datalines;
0.0035,&amp;gt;=0.0035,&amp;lt;=0.034
0.034,&amp;gt;=0.0035,&amp;lt;=0.034
0.0045,&amp;gt;=0.0035,&amp;lt;=0.034
;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Within a Datastep(not _NULL_), I want to evaluate the condition&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;value||lower/*value &amp;gt;=0.0035*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;value||upper/*value &amp;lt;=0.034*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and if the conditions are met then create another variable- flag with value "GOOD" else value should be "BAD".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please advise.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To make this a proper exercise you need to show 1) multiple comparisons that vary between records not just two applied to all records as that is easily done in the code or a format and not worth bothering with read in values; and 2) show what you expect the result to look like.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 21:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764350#M242102</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-26T21:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve Conditions in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764355#M242105</link>
      <description>&lt;P&gt;If this helps:&lt;/P&gt;&lt;P&gt;If the value of the variable-VALUE is within the values of LOWER and UPPER then another variable named FLAG needs to be created with value of "GOOD" else it should have a value of "BAD".&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 21:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764355#M242105</guid>
      <dc:creator>arpitsharma27</dc:creator>
      <dc:date>2021-08-26T21:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve Conditions in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764367#M242108</link>
      <description>&lt;P&gt;You already apparently know:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The values of lower and upper, in eponymously named variables.&lt;/LI&gt;
&lt;LI&gt;And you want always to compare&amp;nbsp; &amp;lt;= or &amp;gt;=&amp;nbsp; &amp;nbsp;(i.e. not strictly &amp;lt; or &amp;gt;).&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;If so, then why are you reading in lower and upper as text?&amp;nbsp; Why not read the numbers and do direct numeric comparisons?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect there must be more to your task than what you have shown.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 22:40:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764367#M242108</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-08-26T22:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve Conditions in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764370#M242110</link>
      <description>&lt;P&gt;Obviously I put a template here. Once I get the idea of how code works, I can use it.&lt;/P&gt;&lt;P&gt;Anyways, I think I figured out&amp;nbsp; using &lt;STRONG&gt;dosubl&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
condition=cats(value,lower);
_n_=dosubl('data _null_ ; call symputx("check", '||condition||'); run;');
check=symget('check');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Aug 2021 23:05:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764370#M242110</guid>
      <dc:creator>arpitsharma27</dc:creator>
      <dc:date>2021-08-26T23:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve Conditions in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764384#M242119</link>
      <description>&lt;P&gt;No macro and no sub-sessions and one clean results table if you do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;
  set HAVE;
  if _N_=1 then call execute('data WANT; length LOWER UPPER $10;');
  call execute(catt('VALUE=', VALUE, ';LOWER="', LOWER, ' ";UPPER="', UPPER, ' "; '); 
  call execute(catx(' ', 'if', VALUE, LOWER, 'then FLAG_LOWER="GOOD";');
  call execute(catx(' ', 'if', VALUE, UPPER, 'then FLAG_UPPER="GOOD";');
  call execute('output;');
run;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 03:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764384#M242119</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-08-27T03:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve Conditions in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764447#M242143</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like your solution, but really it is effectively using a "data _null_" approach.&amp;nbsp; Your code just makes it into a "data want", immediately overwritten by a second "data want".&amp;nbsp; &amp;nbsp;I think the dosubl solution is likely the only way to avoid an "outer" data _NULL_, which I suspect is the criterion meant by the OP.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 12:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764447#M242143</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-08-27T12:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve Conditions in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764468#M242154</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input value lower :$10. upper :$10.;
infile datalines dlm=",";
datalines;
0.0035,&amp;gt;=0.0035,&amp;lt;=0.034
0.034,&amp;gt;=0.0035,&amp;lt;=0.034
0.0045,&amp;gt;=0.0035,&amp;lt;=0.034
0.45,&amp;gt;=0.0035,&amp;lt;=0.034
;run;

data want;
 set have;
 flag=resolve(cat('%sysevalf(',cats(value,lower),' and ',cats(value,upper),',boolean)'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Aug 2021 14:16:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764468#M242154</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-08-27T14:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve Conditions in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764488#M242159</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/179936"&gt;@arpitsharma27&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Obviously I put a template here. Once I get the idea of how code works, I can use it.&lt;/P&gt;
&lt;P&gt;Anyways, I think I figured out&amp;nbsp; using &lt;STRONG&gt;dosubl&lt;/STRONG&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A big caution with simple templates. If they are too simple then you are implying the actual process is less complicated than it actually is. For example, if your real problem involves multiple different comparisons then you should provide examples of those as well.&lt;/P&gt;
&lt;P&gt;Reasons: Your initial post would be much better of just placing the EXACT SAME comparisons into to code. No need to dirty up code for a the same comparison will all values.&lt;/P&gt;
&lt;P&gt;The approaches provided that involve 2 comparisons may not work as expected if there is only one comparison. This is quite likely in the case of only having an Upper comparison that involves &amp;lt; in any form and a missing value. since MISSING is lest than anything. Note: you did not state that the value is never missing. Considerations for that may need to be applied.&lt;/P&gt;
&lt;P&gt;And what happens if you throw in a third comparison? Or another value?&lt;/P&gt;
&lt;P&gt;Providing essentially one use case for the comparison boundaries is quite likely to lead to code that is not quite what is needed.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 15:59:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764488#M242159</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-27T15:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve Conditions in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764604#M242196</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt; The &lt;STRONG&gt;data _null_&lt;/STRONG&gt; restriction is weird, and I see &lt;STRONG&gt;data _null_&lt;/STRONG&gt; in the&lt;STRONG&gt; call dosubl&lt;/STRONG&gt; logic too.&lt;/P&gt;
&lt;P&gt;Not too sure what the end goal is, but if it is just an intellectual exercise to avoid &lt;STRONG&gt;data _null_&lt;/STRONG&gt; then the&lt;STRONG&gt; call dosubl&lt;/STRONG&gt; solution fails too.&lt;/P&gt;
&lt;P&gt;One way would be to do it would be by using a macro and functions open() and getvarn() and resolve the test there. Other than that, a data step is needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Aug 2021 06:43:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764604#M242196</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-08-28T06:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve Conditions in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764607#M242198</link>
      <description>&lt;P&gt;Which comparison operators are to be expected in the lower and upper variables?&lt;/P&gt;
&lt;P&gt;Will lower always contain the low end (and upper the top), or could this be reversed?&lt;/P&gt;</description>
      <pubDate>Sat, 28 Aug 2021 08:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764607#M242198</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-08-28T08:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve Conditions in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764610#M242199</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt; The &lt;STRONG&gt;data _null_&lt;/STRONG&gt; restriction is weird, and I see &lt;STRONG&gt;data _null_&lt;/STRONG&gt; in the&lt;STRONG&gt; call dosubl&lt;/STRONG&gt; logic too.&lt;/P&gt;
&lt;P&gt;Not too sure what the end goal is, but if it is just an intellectual exercise to avoid &lt;STRONG&gt;data _null_&lt;/STRONG&gt; then the&lt;STRONG&gt; call dosubl&lt;/STRONG&gt; solution fails too.&lt;/P&gt;
&lt;P&gt;One way would be to do it would be by using a macro and functions open() and getvarn() and resolve the test there. Other than that, a data step is needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Understood.&amp;nbsp; I took the restriction to mean that there would be no use of DATA _NULL_ in the &lt;EM&gt;&lt;STRONG&gt;outer&lt;/STRONG&gt;&lt;/EM&gt; loop/domain, thereby providing the &lt;STRONG&gt;call dosubl&lt;/STRONG&gt; approach a loophole.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;'s use of the resolve function best suits my understanding of the OP's conditions, and neatly complements the title of this thread ("Resolve Conditions in a datastep").&lt;/P&gt;</description>
      <pubDate>Sat, 28 Aug 2021 10:53:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764610#M242199</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-08-28T10:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve Conditions in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764655#M242221</link>
      <description>Agreed, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; 's reply is probably the best reply so far to match the specs.&lt;BR /&gt;</description>
      <pubDate>Sun, 29 Aug 2021 01:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-Conditions-in-a-datastep/m-p/764655#M242221</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-08-29T01:28:11Z</dc:date>
    </item>
  </channel>
</rss>

