<?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 Find smallest value in variable list in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Find-smallest-value-in-variable-list/m-p/3185#M1415</link>
    <description>I wrote code to calculate the proportion of the normal (0,1) distribution less than x from -2.5 and 0. Now I would like to print out the x value that is closest to the probability value = .10. How do I do this? After looking at the output the x value is -1.30 but I want to find this automatically and print. Any suggestions?&lt;BR /&gt;
&lt;BR /&gt;
data one;&lt;BR /&gt;
do x = -2.5 to 0 by .05;&lt;BR /&gt;
probablity = probnorm(x);&lt;BR /&gt;
difference = abs(.1-probability); *the smallest value of difference and its corresponding x value would be what I want to print out;&lt;BR /&gt;
output;&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=one;&lt;BR /&gt;
run;</description>
    <pubDate>Tue, 22 May 2007 15:44:39 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2007-05-22T15:44:39Z</dc:date>
    <item>
      <title>Find smallest value in variable list</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Find-smallest-value-in-variable-list/m-p/3185#M1415</link>
      <description>I wrote code to calculate the proportion of the normal (0,1) distribution less than x from -2.5 and 0. Now I would like to print out the x value that is closest to the probability value = .10. How do I do this? After looking at the output the x value is -1.30 but I want to find this automatically and print. Any suggestions?&lt;BR /&gt;
&lt;BR /&gt;
data one;&lt;BR /&gt;
do x = -2.5 to 0 by .05;&lt;BR /&gt;
probablity = probnorm(x);&lt;BR /&gt;
difference = abs(.1-probability); *the smallest value of difference and its corresponding x value would be what I want to print out;&lt;BR /&gt;
output;&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=one;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 22 May 2007 15:44:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Find-smallest-value-in-variable-list/m-p/3185#M1415</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-05-22T15:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Find smallest value in variable list</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Find-smallest-value-in-variable-list/m-p/3186#M1416</link>
      <description>I corrected the inconsistent spellings of probability, and added some code to the step.&lt;BR /&gt;
&lt;BR /&gt;
Essentially, you hold a value which is the smallest and compare it to the difference.&lt;BR /&gt;
&lt;BR /&gt;
If difference is lower than smallest then update smallest.&lt;BR /&gt;
&lt;BR /&gt;
Otherwise it is larger and has started to increase again.  So output the record at that point and stop the data step.&lt;BR /&gt;
&lt;BR /&gt;
You now have one record with the smallest value and related X value.&lt;BR /&gt;
&lt;BR /&gt;
If you don't like the column names, issue a rename option on the data statement.&lt;BR /&gt;
&lt;BR /&gt;
Kind regards&lt;BR /&gt;
&lt;BR /&gt;
David&lt;BR /&gt;
&lt;BR /&gt;
Data ONE;&lt;BR /&gt;
  SMALLEST = 9999;&lt;BR /&gt;
  Do X = -2.5  To 0  By .05;&lt;BR /&gt;
    PROBABILITY = ProbNorm( X);&lt;BR /&gt;
    DIFFERENCE = ABS( .1 - PROBABILITY);&lt;BR /&gt;
    * the smallest value of difference and its corresponding &lt;BR /&gt;
      x value would be what I want to print out;&lt;BR /&gt;
    If DIFFERENCE &amp;lt; SMALLEST  Then  Do;&lt;BR /&gt;
      SMALLEST = DIFFERENCE;&lt;BR /&gt;
      XVALUE = X;&lt;BR /&gt;
    End;&lt;BR /&gt;
    Else Do;&lt;BR /&gt;
      Output;&lt;BR /&gt;
      Stop;&lt;BR /&gt;
    End;&lt;BR /&gt;
  End;&lt;BR /&gt;
Run;</description>
      <pubDate>Wed, 23 May 2007 08:08:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Find-smallest-value-in-variable-list/m-p/3186#M1416</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-05-23T08:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: Find smallest value in variable list</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Find-smallest-value-in-variable-list/m-p/3187#M1417</link>
      <description>Thanks David, I really appreciate it.</description>
      <pubDate>Thu, 24 May 2007 15:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Find-smallest-value-in-variable-list/m-p/3187#M1417</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-05-24T15:16:03Z</dc:date>
    </item>
  </channel>
</rss>

