<?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: SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sort-values-in-a-row-observation/m-p/651311#M195409</link>
    <description>&lt;P&gt;&lt;FONT size="6"&gt;&lt;STRONG&gt;DO NOT POST DATA IN PICTURES!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="6"&gt;&lt;FONT size="4"&gt;We are not hired to type data off the screen for testing. Post example in a data step with datalines. Also use descriptive subject lines, as you were advised in your "welcome" mail. Using just "SAS" in&amp;nbsp;&lt;U&gt;&lt;EM&gt;the&lt;/EM&gt;&lt;/U&gt; SAS-oriented online community is not a sign of overwhelming intelligence, to say the least.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 28 May 2020 07:21:56 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-05-28T07:21:56Z</dc:date>
    <item>
      <title>Sort values in a row/observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-values-in-a-row-observation/m-p/651307#M195408</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;My original table is like the following.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ae_w105_0-1590649199831.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/40066iC9F7FF57A9B5D4A1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ae_w105_0-1590649199831.png" alt="ae_w105_0-1590649199831.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Question1:&lt;/P&gt;
&lt;P&gt;Is it possible to sort the values in the columns COL1 to COL4 with the column names remain unchanged.&lt;/P&gt;
&lt;P&gt;Also, the value that is associated with the respective column needs to re-arranged as well.&lt;/P&gt;
&lt;P&gt;For example, B is initially COL3, and the associated value in VAL3 is 400.&lt;/P&gt;
&lt;P&gt;B will be in COL2, so 400 should be in VAL2 as well.&lt;/P&gt;
&lt;P&gt;The desired output is as follows:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ae_w105_1-1590649257956.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/40067i244AE97D759E1296/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ae_w105_1-1590649257956.png" alt="ae_w105_1-1590649257956.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question2:&lt;/P&gt;
&lt;P&gt;Within the same key, compare the values in col1-col4 with that of the previous row.&lt;/P&gt;
&lt;P&gt;If the current row doesn't have values from previous row, create additional columns prev_col: that record those values. Similarly for the val: columns.&lt;/P&gt;
&lt;P&gt;If the current row has new value not found from previous row, create additional columns new_col: that record those values. Similarly for the val: columns.&lt;/P&gt;
&lt;P&gt;The desired output is as follows:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ae_w105_2-1590649473266.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/40068i42EC21C7226E4CC6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ae_w105_2-1590649473266.png" alt="ae_w105_2-1590649473266.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 May 2020 13:26:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-values-in-a-row-observation/m-p/651307#M195408</guid>
      <dc:creator>ae_w105</dc:creator>
      <dc:date>2020-05-28T13:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-values-in-a-row-observation/m-p/651311#M195409</link>
      <description>&lt;P&gt;&lt;FONT size="6"&gt;&lt;STRONG&gt;DO NOT POST DATA IN PICTURES!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="6"&gt;&lt;FONT size="4"&gt;We are not hired to type data off the screen for testing. Post example in a data step with datalines. Also use descriptive subject lines, as you were advised in your "welcome" mail. Using just "SAS" in&amp;nbsp;&lt;U&gt;&lt;EM&gt;the&lt;/EM&gt;&lt;/U&gt; SAS-oriented online community is not a sign of overwhelming intelligence, to say the least.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 May 2020 07:21:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-values-in-a-row-observation/m-p/651311#M195409</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-28T07:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-values-in-a-row-observation/m-p/651316#M195411</link>
      <description>&lt;P&gt;You can try the call sort function as below and it should generate the expected result&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call sort(col1,col2,col3,col4);
call sort(val1,val2,val3,val4);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 May 2020 07:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-values-in-a-row-observation/m-p/651316#M195411</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-05-28T07:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS sorting an array of numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sort-values-in-a-row-observation/m-p/651520#M195486</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the various call routines return their value in their arguments, in this case the array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this code is on page 5 of the paper cited below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   array  _n(&amp;amp;n_obs);
do _i = 1 to &amp;amp;n_obs ;   * read column into row;
   set &amp;amp;data (keep   =  &amp;amp;name
              rename = (&amp;amp;name = _value))
       point = _i;
   _n(_i) = _value;
   end;

call sortn(of _n(*));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;@inproceedings{Fehd-2015_mwsug-rf-04_read-column-into-row,&lt;BR /&gt;year=2015,booktitle=name.mwsug,author={Ronald J. Fehd},&lt;BR /&gt;title ={Reading a Column into a Row to Count N-levels,&lt;BR /&gt;Calculate Cardinality Ratio and Create Frequency and Summary Output In One Step},&lt;BR /&gt;note ={Rapid Fire, 10 pp.},&lt;BR /&gt;url={&lt;A href="http://www.lexjansen.com/mwsug/2015/RF/MWSUG-2015-RF-04.pdf" target="_blank"&gt;http://www.lexjansen.com/mwsug/2015/RF/MWSUG-2015-RF-04.pdf&lt;/A&gt;}}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 May 2020 19:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sort-values-in-a-row-observation/m-p/651520#M195486</guid>
      <dc:creator>Ron_MacroMaven</dc:creator>
      <dc:date>2020-05-28T19:16:03Z</dc:date>
    </item>
  </channel>
</rss>

