<?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: sql conditionally print max of variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461102#M117251</link>
    <description>&lt;P&gt;please provide a sample of what you "have" and what you "want" data?&amp;nbsp; We the community will be able to provide various solutions from which you can choose and pick&lt;/P&gt;</description>
    <pubDate>Wed, 09 May 2018 15:59:19 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-05-09T15:59:19Z</dc:date>
    <item>
      <title>sql conditionally print max of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461090#M117245</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data set have variables from&amp;nbsp; v1 to v1000, I'd like to print ids and the max of those variables if the max of them is above 1. I tried sql command but my code does not work:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table max as 
  select id, max(v1-v1000)
  from data
  where max(v1-v1000) &amp;gt; 1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any suggestions? Thanks!!&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2018 15:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461090#M117245</guid>
      <dc:creator>panda</dc:creator>
      <dc:date>2018-05-09T15:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: sql conditionally print max of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461096#M117248</link>
      <description>&lt;P&gt;change to having&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token statement"&gt;having &lt;/SPAN&gt;&lt;SPAN class="token function"&gt;max&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;v1&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;v1000&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 May 2018 15:53:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461096#M117248</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-09T15:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: sql conditionally print max of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461099#M117249</link>
      <description>&lt;P&gt;Thanks, the code ran without error but did not generate the results I have in mind. I want to show max of each of column if the max of column is above 1. For instance, if I have 10 variables with max &amp;gt; 1, I'd like to see ten rows of max in the output.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2018 15:57:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461099#M117249</guid>
      <dc:creator>panda</dc:creator>
      <dc:date>2018-05-09T15:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: sql conditionally print max of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461102#M117251</link>
      <description>&lt;P&gt;please provide a sample of what you "have" and what you "want" data?&amp;nbsp; We the community will be able to provide various solutions from which you can choose and pick&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2018 15:59:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461102#M117251</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-09T15:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: sql conditionally print max of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461105#M117252</link>
      <description>&lt;P&gt;Variable lists are not supported in proc SQL. Use a data step instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data max;
set data;
sum_v = sum(of v1-v1000);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 May 2018 16:06:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461105#M117252</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-05-09T16:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: sql conditionally print max of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461106#M117253</link>
      <description>&lt;P&gt;&lt;SPAN&gt;The data I have is like this:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data; 
input id $ v1 v2 v3 v4 v5; 
datalines;
a 1 1 1 1 1
b 2 0 0 1 1
c 1 2 0 0 0
d 1 1 1 1 0
; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;I want the output like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input id $ max;
datalines;
b 2
c 2
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;Many thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2018 16:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461106#M117253</guid>
      <dc:creator>panda</dc:creator>
      <dc:date>2018-05-09T16:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: sql conditionally print max of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461107#M117254</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data; 
input id $ v1 v2 v3 v4 v5; 
datalines;
a 1 1 1 1 1
b 2 0 0 1 1
c 1 2 0 0 0
d 1 1 1 1 0
; 

proc sql;
create table want as
select id, max(v1, v2, v3, v4, v5) as max
from data
having max=max( max);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 May 2018 16:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461107#M117254</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-09T16:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: sql conditionally print max of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461108#M117255</link>
      <description>&lt;P&gt;Thanks! I think change sum to max and then use proc print can get what I want. It seems that sql cannot select v1-v1000 without typing each of the variable names.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data max;
  set have;
  max = max(of v1-v1440);
  keep id max;
run;

proc print data = max;
 var id max;
 where max &amp;gt; 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 May 2018 16:16:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461108#M117255</guid>
      <dc:creator>panda</dc:creator>
      <dc:date>2018-05-09T16:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: sql conditionally print max of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461129#M117261</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151080"&gt;@panda&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thanks! I think change sum to max and then use proc print can get what I want. It seems that sql cannot select v1-v1000 without typing each of the variable names.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is what the previous comment by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;about Proc SQL not accepting variable lists means. V1- V1000 is a variable list..&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2018 17:27:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sql-conditionally-print-max-of-variables/m-p/461129#M117261</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-09T17:27:55Z</dc:date>
    </item>
  </channel>
</rss>

