<?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: Swap values row wise in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Swap-values-row-wise/m-p/944031#M369946</link>
    <description>&lt;P&gt;If that's not just an "academic" question then you will likely need to provide more information to get a suitable answer.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please also provide a fully working data step that creates the have data and show us the desired result so we understand if that's about switching values between variables on a single row or if it is about swapping rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variable swap:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines dlm=' ';
  input var1-var5;
  _v=var2;
  var2=var4;
  var4=_v;
  drop _v;
Cards;
12 33 56 77 99
;
run;

proc print data=have;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Row swap:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines dlm=' ';
  input var @@;
Cards;
12 33 56 77 99
;
run;

data want;
  do _i=1,4,3,2,5;
    set have point=_i;
    output;
  end;
  stop;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 16 Sep 2024 04:30:23 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2024-09-16T04:30:23Z</dc:date>
    <item>
      <title>Swap values row wise</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Swap-values-row-wise/m-p/944030#M369945</link>
      <description>Input values ;&lt;BR /&gt;Cards &lt;BR /&gt;12 33 56 77 99;&lt;BR /&gt;run&lt;BR /&gt;Q.) swap 33  and 77  values remaining keep same &lt;BR /&gt;Output&lt;BR /&gt;12 77 56 33 99&lt;BR /&gt;</description>
      <pubDate>Mon, 16 Sep 2024 04:14:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Swap-values-row-wise/m-p/944030#M369945</guid>
      <dc:creator>pavank</dc:creator>
      <dc:date>2024-09-16T04:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: Swap values row wise</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Swap-values-row-wise/m-p/944031#M369946</link>
      <description>&lt;P&gt;If that's not just an "academic" question then you will likely need to provide more information to get a suitable answer.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please also provide a fully working data step that creates the have data and show us the desired result so we understand if that's about switching values between variables on a single row or if it is about swapping rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variable swap:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines dlm=' ';
  input var1-var5;
  _v=var2;
  var2=var4;
  var4=_v;
  drop _v;
Cards;
12 33 56 77 99
;
run;

proc print data=have;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Row swap:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines dlm=' ';
  input var @@;
Cards;
12 33 56 77 99
;
run;

data want;
  do _i=1,4,3,2,5;
    set have point=_i;
    output;
  end;
  stop;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Sep 2024 04:30:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Swap-values-row-wise/m-p/944031#M369946</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-09-16T04:30:23Z</dc:date>
    </item>
  </channel>
</rss>

