<?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 replace the value.. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-value/m-p/109041#M22673</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, Merge seems to me very efficient if it does not look to match By variables like in this case. Another look-ahead alternative is to try SET statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test(keep=name);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test(keep=age firstobs=2) test(obs=1 drop=_all_);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Dec 2012 14:28:01 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2012-12-27T14:28:01Z</dc:date>
    <item>
      <title>How to replace the value..</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-value/m-p/109037#M22669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a data like mentioned below..&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;input name $ age;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;aa .&lt;/P&gt;&lt;P&gt;bb 1&lt;/P&gt;&lt;P&gt;cc 2&lt;/P&gt;&lt;P&gt;dd 3&lt;/P&gt;&lt;P&gt;ee .&lt;/P&gt;&lt;P&gt;ff 5&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to replace the values of age..that means second value should be in first place, 3rd should be in 2nd, 4th should be in&amp;nbsp; 3rd..so on .. Please help me..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output should be like below/..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Name age&lt;/P&gt;&lt;P&gt;aa 1&lt;/P&gt;&lt;P&gt;bb 2&lt;/P&gt;&lt;P&gt;cc 3&lt;/P&gt;&lt;P&gt;dd .&lt;/P&gt;&lt;P&gt;ee 5&lt;/P&gt;&lt;P&gt;ff .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;P&gt;Yaswanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Dec 2012 10:04:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-value/m-p/109037#M22669</guid>
      <dc:creator>yaswanthj</dc:creator>
      <dc:date>2012-12-27T10:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the value..</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-value/m-p/109038#M22670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds like an excercise so instead of simply asking for the question and learning nothing you should show us what you've already done and where you've got stuck. Just getting solutions won't help you to become a skilled developer.&lt;/P&gt;&lt;P&gt;But o.k., here you go. If it's study: Make sure you understand 100% what's going on here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge test(keep=name) test(keep=age firstobs=2);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Dec 2012 11:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-value/m-p/109038#M22670</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-12-27T11:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the value..</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-value/m-p/109039#M22671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Patrick&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your solutions looks smart and easy for above post and bellow one too..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="148747" __jive_macro_name="message" class="jive_macro jive_macro_message" href="https://communities.sas.com/" modifiedtitle="true" title="Re: Find difference between two dates.."&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But in the context of Huge data,is above method help full?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It might take lot time to process right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clarify me...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sanjeev.K&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Dec 2012 11:24:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-value/m-p/109039#M22671</guid>
      <dc:creator>kuridisanjeev</dc:creator>
      <dc:date>2012-12-27T11:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the value..</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-value/m-p/109040#M22672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Patrick..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;your Mentioned code is working fine ..and also working for below post..&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="39657" __jive_macro_name="thread" class="jive_macro jive_macro_thread" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried with your code it is working..but it is taking long time when i execute for huge data in V9.1, the folk sanjeev mentioned in this post..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please let me know, is there any other ways to do..with out using merge statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Yaswanth &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Dec 2012 11:40:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-value/m-p/109040#M22672</guid>
      <dc:creator>yaswanthj</dc:creator>
      <dc:date>2012-12-27T11:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the value..</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-value/m-p/109041#M22673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, Merge seems to me very efficient if it does not look to match By variables like in this case. Another look-ahead alternative is to try SET statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test(keep=name);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test(keep=age firstobs=2) test(obs=1 drop=_all_);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Dec 2012 14:28:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-value/m-p/109041#M22673</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-12-27T14:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the value..</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-value/m-p/109042#M22674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is another approach, almost as efficient as Hai.Kuo's:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; new(keep=name age);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dsid=open(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple; font-size: 10pt;"&gt;"test"&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nrows=attrn(dsid,&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple; font-size: 10pt;"&gt;"NOBS"&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; k=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt; nrows;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc1=fetchobs(dsid,k);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name=getvarc(dsid,&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc2=fetchobs(dsid,k+&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; age=getvarn(dsid,&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Dec 2012 16:18:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-value/m-p/109042#M22674</guid>
      <dc:creator>joehinson</dc:creator>
      <dc:date>2012-12-27T16:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace the value..</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-value/m-p/109043#M22675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or put lag() function on variable name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data test;
input name $ age;
cards;
aa .
bb 1
cc 2
dd 3
ee .
ff 5
;
run;
data want;
 set test end=last;
 _name=lag(name);
if _n_ gt 1&amp;nbsp; then do;output; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if last then do;_name=name;age=.;output;end;
end;
drop name;

run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KSharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Dec 2012 02:07:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-the-value/m-p/109043#M22675</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-12-28T02:07:10Z</dc:date>
    </item>
  </channel>
</rss>

