<?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 missing values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/swaping-missing-values/m-p/303108#M64350</link>
    <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input sub $ score;
datalines;
001 120
001 .
002 220
001 .
002 .
003 .
003 230
;
run;

data want;
set have;
retain x1;
if score = .
then score = x1;
else x1 = score;
drop x1;
run;

proc print noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;sub    score

001     120 
001     120 
002     220 
001     220 
002     220 
003     220 
003     230 
&lt;/PRE&gt;</description>
    <pubDate>Fri, 07 Oct 2016 06:46:25 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-10-07T06:46:25Z</dc:date>
    <item>
      <title>swaping missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/swaping-missing-values/m-p/303106#M64348</link>
      <description>&lt;P&gt;Hi Experts,&lt;BR /&gt;I need to swap missing value with above value so please help me in the same.&lt;BR /&gt;&lt;BR /&gt;data abc;&lt;BR /&gt;input sub $ score;&lt;BR /&gt;datalines;&lt;BR /&gt;001 120&lt;BR /&gt;001 .&lt;BR /&gt;002 220&lt;BR /&gt;001 .&lt;BR /&gt;002 .&lt;BR /&gt;003 .&lt;BR /&gt;003 230&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;data abc1;&lt;BR /&gt;set abc;&lt;BR /&gt;score2=lag(score);&lt;BR /&gt;if score = . then score=lag(score);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;WANT&lt;BR /&gt;001 120&lt;BR /&gt;001 120&lt;BR /&gt;002 220&lt;BR /&gt;001 220&lt;BR /&gt;002 220&lt;BR /&gt;003 220&lt;BR /&gt;003 230&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thnx&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 06:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/swaping-missing-values/m-p/303106#M64348</guid>
      <dc:creator>Rahul_SAS</dc:creator>
      <dc:date>2016-10-07T06:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: swaping missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/swaping-missing-values/m-p/303107#M64349</link>
      <description>&lt;P&gt;Hi Rahul&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;below can do the trick&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; abc1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;retain&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; score;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; abc(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;rename&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=(score=score2));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; score2 ne &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; score=score2;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;drop&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; score2;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 06:38:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/swaping-missing-values/m-p/303107#M64349</guid>
      <dc:creator>Tom_C_Mortensen</dc:creator>
      <dc:date>2016-10-07T06:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: swaping missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/swaping-missing-values/m-p/303108#M64350</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input sub $ score;
datalines;
001 120
001 .
002 220
001 .
002 .
003 .
003 230
;
run;

data want;
set have;
retain x1;
if score = .
then score = x1;
else x1 = score;
drop x1;
run;

proc print noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;sub    score

001     120 
001     120 
002     220 
001     220 
002     220 
003     220 
003     230 
&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Oct 2016 06:46:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/swaping-missing-values/m-p/303108#M64350</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-10-07T06:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: swaping missing values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/swaping-missing-values/m-p/303196#M64365</link>
      <description>&lt;P&gt;Hi KurtBremser,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have one more point, if the first observation has a missing value then how will it work??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thnx&lt;/P&gt;
&lt;P&gt;rahul&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 15:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/swaping-missing-values/m-p/303196#M64365</guid>
      <dc:creator>Rahul_SAS</dc:creator>
      <dc:date>2016-10-07T15:21:47Z</dc:date>
    </item>
  </channel>
</rss>

