<?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: Swaping observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290883#M60247</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;&amp;nbsp;Simple and very effective.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Aug 2016 06:18:59 GMT</pubDate>
    <dc:creator>RahulG</dc:creator>
    <dc:date>2016-08-11T06:18:59Z</dc:date>
    <item>
      <title>Swaping observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290711#M60182</link>
      <description>Hi Experts,

Is there any way to swap two or more observations within a dataset like I want to swap 15th observation with 83rd.

Please help.

Regards</description>
      <pubDate>Wed, 10 Aug 2016 13:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290711#M60182</guid>
      <dc:creator>Rahul_SAS</dc:creator>
      <dc:date>2016-08-10T13:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Swaping observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290713#M60183</link>
      <description>&lt;P&gt;You may have to write a macro to swap row.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2016 14:10:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290713#M60183</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-08-10T14:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Swaping observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290714#M60184</link>
      <description>&lt;P&gt;Thats not logical. &amp;nbsp;Why the 15th and why the 83rd? &amp;nbsp;You can do it by using the _n_ automatic variable but I would really advise against it as any change to that data (sorting, logic etc.) would mess up that change. &amp;nbsp;You would be better off looking at why you select the 15th and 83rd rows and then use that selection criteria to pull out the rows you want and swap them over. &amp;nbsp;Also bear in mind that there are sort procedures and such like that sort the data based on key variables, not position in the dataset. &amp;nbsp;You may be thinking in Excel terms, don't, SAS datasets are logically ordered and manipulated.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2016 14:11:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290714#M60184</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-10T14:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: Swaping observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290731#M60188</link>
      <description>&lt;P&gt;You would need to re-create the data set.&amp;nbsp; And it's clumsy.&amp;nbsp; This would be one way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;do until (done1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have (obs=14) end=done1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;set have (firstobs=83 obs=83);&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;do until (done2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have (firstobs=16 obs=82) end=done2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;set have (firstobs=15 obs=15);&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;do until (done3);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have (firstobs=84) end=done3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This would be easier (less clumsy), but probably takes longer to run:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;do _n_=1 to 14, 83, 16 to 82, 15, 84 to _nobs_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have nobs=_nobs_ point=_n_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;stop;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code is untested, but should be OK.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2016 15:04:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290731#M60188</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-10T15:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: Swaping observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290867#M60243</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;could you please explain a bit how POINT options is working here??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-Rahul&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 04:28:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290867#M60243</guid>
      <dc:creator>Rahul_SAS</dc:creator>
      <dc:date>2016-08-11T04:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: Swaping observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290880#M60246</link>
      <description>&lt;PRE&gt;
Why not make a index variable N and proc sort it ?

data have;
 do i=1 to 100;
  output;
 end;
run;

data want;
 set have;
 n=_n_;
 if n=15 then n=84;
  else if n=84 then n=15;
run;
proc sort data=want;by n;run;

&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Aug 2016 05:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290880#M60246</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-08-11T05:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Swaping observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290883#M60247</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;&amp;nbsp;Simple and very effective.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 06:18:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290883#M60247</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-08-11T06:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: Swaping observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290900#M60250</link>
      <description>&lt;P&gt;Point options make set statement to read data from observation number mentioned with point = .&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 07:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Swaping-observations/m-p/290900#M60250</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-08-11T07:38:42Z</dc:date>
    </item>
  </channel>
</rss>

