<?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: A unusual result from creating a lead variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/A-unusual-result-from-creating-a-lead-variable/m-p/638850#M21621</link>
    <description>&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is really bizarre. I asked two of my colleagues to run the code. One with 64 bit SAS generated the correct result; the other one with 32 bit SAS (the same as mine) generated the result the same as mine.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Apr 2020 02:03:01 GMT</pubDate>
    <dc:creator>NanZ</dc:creator>
    <dc:date>2020-04-10T02:03:01Z</dc:date>
    <item>
      <title>A unusual result from creating a lead variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/A-unusual-result-from-creating-a-lead-variable/m-p/638800#M21609</link>
      <description>&lt;P&gt;Hi SAS users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I met a very strange situation&amp;nbsp;when creating a lead variable or I had a very low level mistake in my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code and example data are as the following.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After run the code, the lead_datein for time = 2 should be equal to the last datin or 2008-09-15. But the created lead_datein actually is 2008-09-14, which the value comes from nowhere. The lead_dateout is also not right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;&amp;nbsp;input clientid datein dateout;&lt;BR /&gt;&amp;nbsp;datalines;&lt;BR /&gt;1 16519 16523&lt;BR /&gt;1 17779 17786&lt;BR /&gt;1 17789 17790&lt;BR /&gt;1 17790 17794&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sort data= have; by clientid datein dateout; run;&lt;/P&gt;&lt;P&gt;proc expand data= have&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; out= want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;convert datein&amp;nbsp; = lead_datein&amp;nbsp; /transformout = (lead 1);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;convert dateout = lead_dateout /transformout = (lead 1);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;by clientid;&lt;BR /&gt;&amp;nbsp;run;&lt;/P&gt;&lt;P&gt;data want ;&lt;BR /&gt;&amp;nbsp;format clientid time datin datout lead_datin lead_datout&amp;nbsp; ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;set want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;format lead_datein yymmdd10. lead_dateout&amp;nbsp; yymmdd10. datein yymmdd10. dateout&amp;nbsp; yymmdd10. ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;label lead_datein="lead_datin";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;label lead_dateout="lead_datout";&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;* Change datout and lead_datout (generated from creating the Lead_ variable) back to missing;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;*if flag_datout_missing_all = 1 then datout = . ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;if dateout&amp;gt;lead_datein and lead_datein &amp;gt; 0 then flag1 = 1 ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 21:09:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/A-unusual-result-from-creating-a-lead-variable/m-p/638800#M21609</guid>
      <dc:creator>NanZ</dc:creator>
      <dc:date>2020-04-09T21:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: A unusual result from creating a lead variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/A-unusual-result-from-creating-a-lead-variable/m-p/638809#M21612</link>
      <description>&lt;P&gt;I get this out of proc expand, which seems OK to me:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;clientid TIME 	lead_datein 	lead_dateout 	datein 	        dateout
1 	 0 	2008-09-04 	2008-09-11 	2005-03-24 	2005-03-28
1 	 1 	2008-09-14 	2008-09-15 	2008-09-04 	2008-09-11
1 	 2 	2008-09-15 	2008-09-19 	2008-09-14 	2008-09-15
1 	 3 	. 	        . 	        2008-09-15 	2008-09-19&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Apr 2020 21:32:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/A-unusual-result-from-creating-a-lead-variable/m-p/638809#M21612</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-04-09T21:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: A unusual result from creating a lead variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/A-unusual-result-from-creating-a-lead-variable/m-p/638850#M21621</link>
      <description>&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is really bizarre. I asked two of my colleagues to run the code. One with 64 bit SAS generated the correct result; the other one with 32 bit SAS (the same as mine) generated the result the same as mine.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 02:03:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/A-unusual-result-from-creating-a-lead-variable/m-p/638850#M21621</guid>
      <dc:creator>NanZ</dc:creator>
      <dc:date>2020-04-10T02:03:01Z</dc:date>
    </item>
  </channel>
</rss>

