<?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: how to use select into creating a macro array with numeric value descending in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-select-into-creating-a-macro-array-with-numeric-value/m-p/442692#M110711</link>
    <description>&lt;P&gt;SQL doesn't promise the order of anything, except when you use an ORDER BY clause.&amp;nbsp; And that doesn't apply to macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do have the option (if it is appropriate) of adding DISTINCT:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select distinct numvalue into : ..........&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DISTINCT forces the order to be ascending.&amp;nbsp; However, it also removes duplicates which may not be what you want.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Mar 2018 01:25:17 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-03-06T01:25:17Z</dc:date>
    <item>
      <title>how to use select into creating a macro array with numeric value descending</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-select-into-creating-a-macro-array-with-numeric-value/m-p/442687#M110710</link>
      <description>&lt;P&gt;I am use select into creating a macro array&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select numValue into:num_value separated by ' ' from tableA;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put %scan(num_value,1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;however,the value in macro num_value&amp;nbsp; did not arrange their numeric values from its original order（from small to large）.&lt;/P&gt;&lt;P&gt;so how could I arrage their values descending or ascending depending on their index,or the macro array has a same order as the original table is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 06 Mar 2018 01:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-select-into-creating-a-macro-array-with-numeric-value/m-p/442687#M110710</guid>
      <dc:creator>Geo-</dc:creator>
      <dc:date>2018-03-06T01:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to use select into creating a macro array with numeric value descending</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-select-into-creating-a-macro-array-with-numeric-value/m-p/442692#M110711</link>
      <description>&lt;P&gt;SQL doesn't promise the order of anything, except when you use an ORDER BY clause.&amp;nbsp; And that doesn't apply to macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do have the option (if it is appropriate) of adding DISTINCT:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select distinct numvalue into : ..........&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DISTINCT forces the order to be ascending.&amp;nbsp; However, it also removes duplicates which may not be what you want.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Mar 2018 01:25:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-select-into-creating-a-macro-array-with-numeric-value/m-p/442692#M110711</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-06T01:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to use select into creating a macro array with numeric value descending</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-select-into-creating-a-macro-array-with-numeric-value/m-p/442713#M110715</link>
      <description>&lt;P&gt;DISTINCT forces the order,and return&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;start&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;25.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;33.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;42.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;54.5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;98&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but when I am using %put %scan(&amp;amp;start_num,1);&lt;/P&gt;&lt;P&gt;it gave me :25&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put %scan(&amp;amp;start_num,2);&lt;/P&gt;&lt;P&gt;return me:533&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;why and how to fix it?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Mar 2018 02:46:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-select-into-creating-a-macro-array-with-numeric-value/m-p/442713#M110715</guid>
      <dc:creator>Geo-</dc:creator>
      <dc:date>2018-03-06T02:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to use select into creating a macro array with numeric value descending</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-select-into-creating-a-macro-array-with-numeric-value/m-p/442717#M110716</link>
      <description>&lt;P&gt;By default, a decimal point is a delimiter for %SCAN.&amp;nbsp; So you have to specify that a blank is the only delimiter:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put %scan(&amp;amp;start_num, 1, %str( ));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, make sure you have a blank in quotes:&amp;nbsp; separated by ' '&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you omit the blank, SQL will use 0 characters as the delimiter:&amp;nbsp; separated by ''&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Mar 2018 02:52:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-select-into-creating-a-macro-array-with-numeric-value/m-p/442717#M110716</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-06T02:52:18Z</dc:date>
    </item>
  </channel>
</rss>

