<?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 proc sql: How can I scan a table? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-How-can-I-scan-a-table/m-p/19993#M4119</link>
    <description>Hi everyone!!&lt;BR /&gt;
&lt;BR /&gt;
I'm a spanish student, and I need to scan a table in SAS, register by register, to make an update on every row (depending of several conditions that include variables in previous row)&lt;BR /&gt;
&lt;BR /&gt;
For example, I want to modify the field Date2 in this example with de field Date of the previous field, if the previous row is the same ID:&lt;BR /&gt;
&lt;BR /&gt;
Initially: &lt;BR /&gt;
&lt;BR /&gt;
ID      DATE                   DATE2&lt;BR /&gt;
1       "25-Oct-2000"        ""&lt;BR /&gt;
1       "30-Oct-2001"        ""&lt;BR /&gt;
1       "25-Nov-2002"        "" &lt;BR /&gt;
2       "13-Jan-2000"        ""&lt;BR /&gt;
2       "15-Mar-2001"        ""&lt;BR /&gt;
&lt;BR /&gt;
Finally&lt;BR /&gt;
&lt;BR /&gt;
ID      DATE                   DATE2&lt;BR /&gt;
1       "25-Oct-2000"        ""&lt;BR /&gt;
1       "30-Oct-2001"        "25-Oct-2000"&lt;BR /&gt;
1       "25-Nov-2002"        "30-Oct-2001" &lt;BR /&gt;
2       "13-Jan-2000"        ""&lt;BR /&gt;
2       "15-Mar-2001"        "13-Jan-2000"&lt;BR /&gt;
&lt;BR /&gt;
Thanks and sorry for my english (is very poor)!!!!!</description>
    <pubDate>Thu, 22 May 2008 08:24:33 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-05-22T08:24:33Z</dc:date>
    <item>
      <title>proc sql: How can I scan a table?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-How-can-I-scan-a-table/m-p/19993#M4119</link>
      <description>Hi everyone!!&lt;BR /&gt;
&lt;BR /&gt;
I'm a spanish student, and I need to scan a table in SAS, register by register, to make an update on every row (depending of several conditions that include variables in previous row)&lt;BR /&gt;
&lt;BR /&gt;
For example, I want to modify the field Date2 in this example with de field Date of the previous field, if the previous row is the same ID:&lt;BR /&gt;
&lt;BR /&gt;
Initially: &lt;BR /&gt;
&lt;BR /&gt;
ID      DATE                   DATE2&lt;BR /&gt;
1       "25-Oct-2000"        ""&lt;BR /&gt;
1       "30-Oct-2001"        ""&lt;BR /&gt;
1       "25-Nov-2002"        "" &lt;BR /&gt;
2       "13-Jan-2000"        ""&lt;BR /&gt;
2       "15-Mar-2001"        ""&lt;BR /&gt;
&lt;BR /&gt;
Finally&lt;BR /&gt;
&lt;BR /&gt;
ID      DATE                   DATE2&lt;BR /&gt;
1       "25-Oct-2000"        ""&lt;BR /&gt;
1       "30-Oct-2001"        "25-Oct-2000"&lt;BR /&gt;
1       "25-Nov-2002"        "30-Oct-2001" &lt;BR /&gt;
2       "13-Jan-2000"        ""&lt;BR /&gt;
2       "15-Mar-2001"        "13-Jan-2000"&lt;BR /&gt;
&lt;BR /&gt;
Thanks and sorry for my english (is very poor)!!!!!</description>
      <pubDate>Thu, 22 May 2008 08:24:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-How-can-I-scan-a-table/m-p/19993#M4119</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-22T08:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql: How can I scan a table?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-How-can-I-scan-a-table/m-p/19994#M4120</link>
      <description>Hi, not sure how to do it in Proc SQL, but in base SAS it can be done this way:&lt;BR /&gt;
&lt;BR /&gt;
Data &lt;INSERT tablename=""&gt;;&lt;BR /&gt;
  Set &lt;INSERT tablename=""&gt;;&lt;BR /&gt;
  By Id;&lt;BR /&gt;
  DATE2=lag(DATE);&lt;BR /&gt;
  If first.ID then DATE2="";&lt;BR /&gt;
Run;&lt;/INSERT&gt;&lt;/INSERT&gt;</description>
      <pubDate>Thu, 22 May 2008 08:39:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-How-can-I-scan-a-table/m-p/19994#M4120</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-22T08:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql: How can I scan a table?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-How-can-I-scan-a-table/m-p/19995#M4121</link>
      <description>Thanks!!&lt;BR /&gt;
&lt;BR /&gt;
One doubt more: with your code, the last row in the final table is deleted. do you know why?</description>
      <pubDate>Thu, 22 May 2008 09:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-How-can-I-scan-a-table/m-p/19995#M4121</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-22T09:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql: How can I scan a table?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-How-can-I-scan-a-table/m-p/19996#M4122</link>
      <description>Fixed!!!&lt;BR /&gt;
&lt;BR /&gt;
Other question. How can I define and work with a variable into a data segment?</description>
      <pubDate>Thu, 22 May 2008 10:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-How-can-I-scan-a-table/m-p/19996#M4122</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-22T10:03:46Z</dc:date>
    </item>
  </channel>
</rss>

