<?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 get the minimum value of one variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/get-the-minimum-value-of-one-variable/m-p/99769#M20993</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to extract the observation with the minimum value of one variable ( with all other variables for this observation) from over several hundred tables created in a macro program. I can combine these tables and get the observation with the minimum value of the variable, is there any efficient way to do this? Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro runit;&lt;/P&gt;&lt;P&gt;%do i =1 %to 15;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %do j = 1 %to 15-&amp;amp;i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %D(&amp;amp;i,&amp;amp;i, &amp;amp;j, &amp;amp;j);run;&amp;nbsp; *** will create one table;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Dec 2012 06:00:43 GMT</pubDate>
    <dc:creator>jojo</dc:creator>
    <dc:date>2012-12-14T06:00:43Z</dc:date>
    <item>
      <title>get the minimum value of one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-the-minimum-value-of-one-variable/m-p/99769#M20993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to extract the observation with the minimum value of one variable ( with all other variables for this observation) from over several hundred tables created in a macro program. I can combine these tables and get the observation with the minimum value of the variable, is there any efficient way to do this? Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro runit;&lt;/P&gt;&lt;P&gt;%do i =1 %to 15;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %do j = 1 %to 15-&amp;amp;i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %D(&amp;amp;i,&amp;amp;i, &amp;amp;j, &amp;amp;j);run;&amp;nbsp; *** will create one table;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 06:00:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-the-minimum-value-of-one-variable/m-p/99769#M20993</guid>
      <dc:creator>jojo</dc:creator>
      <dc:date>2012-12-14T06:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: get the minimum value of one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-the-minimum-value-of-one-variable/m-p/99770#M20994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; having var=min(var);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should ba a start .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 08:39:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-the-minimum-value-of-one-variable/m-p/99770#M20994</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-12-14T08:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: get the minimum value of one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-the-minimum-value-of-one-variable/m-p/99771#M20995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PROC SUMMARY is good for this type of problem.&amp;nbsp; Here's an example that returns the record with the lowest age in SASHELP.CLASS.&amp;nbsp; Note that if there is more than 1 record with the same minimum value then this procedure will only return the first one (i.e. it always returns only 1 record).&amp;nbsp; If you need to return all records with the minimum value then I would suggest PROC SQL, although this method is likely to be slower than PROC SUMMARY (provided there's enough memory for SUMMARY to work!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc summary data=sashelp.class nway;&lt;/P&gt;&lt;P&gt;output out=want1 (drop=_:) minid(age(_all_))=;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want2 as&lt;/P&gt;&lt;P&gt;select * from sashelp.class&lt;/P&gt;&lt;P&gt;having age=min(age);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 08:44:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-the-minimum-value-of-one-variable/m-p/99771#M20995</guid>
      <dc:creator>Keith</dc:creator>
      <dc:date>2012-12-14T08:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: get the minimum value of one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-the-minimum-value-of-one-variable/m-p/99772#M20996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your help. I know this is for exacting the mini from one table, what I need is to get the mini over several hundred tables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 17:18:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-the-minimum-value-of-one-variable/m-p/99772#M20996</guid>
      <dc:creator>jojo</dc:creator>
      <dc:date>2012-12-14T17:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: get the minimum value of one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-the-minimum-value-of-one-variable/m-p/99773#M20997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Get the minimum from each table (and the corresponding fields) and then identify the minimum from that list, that will be the overall minimum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's a bunch of ways to do that, but it depends on how your tables are named. If you're creating it in a loop, your best off finding the minimum each loop and appending that to a table to check later on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What happens if you have multiple minimums, ie observations with the same value that is the minimum.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 17:27:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-the-minimum-value-of-one-variable/m-p/99773#M20997</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-12-14T17:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: get the minimum value of one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-the-minimum-value-of-one-variable/m-p/99774#M20998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could try using a dataset list in a datastep view. Assuming that your datasets names all have the same prefix (untested) :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data allScan / view=allScan;&lt;/P&gt;&lt;P&gt;retain minValue 99999;&lt;/P&gt;&lt;P&gt;set myPREFIX: indsname=dsname;&lt;/P&gt;&lt;P&gt;if myVar &amp;lt; minValue then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; minValue = myVar;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data minObs;&lt;/P&gt;&lt;P&gt;set allScan end=last;&lt;/P&gt;&lt;P&gt;if last then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 17:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-the-minimum-value-of-one-variable/m-p/99774#M20998</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-12-14T17:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: get the minimum value of one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/get-the-minimum-value-of-one-variable/m-p/99775#M20999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! I need to get all records with the mini value, so I created a dataset view and used proc sql to get those records. Thanks very much for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 19:52:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/get-the-minimum-value-of-one-variable/m-p/99775#M20999</guid>
      <dc:creator>jojo</dc:creator>
      <dc:date>2012-12-14T19:52:59Z</dc:date>
    </item>
  </channel>
</rss>

