<?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 check if customer exist in basic  year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596811#M171897</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;For each customer (ID) there are multiple rows.&lt;/P&gt;
&lt;P&gt;Target: have one row for each customer with the original raw data in the last raw&amp;nbsp; and create a new field called "Ind" that get value 1 if year in first row for customer=2017 and 0 otherwise.&lt;/P&gt;
&lt;P&gt;I expect to get following output table:&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp;2019&amp;nbsp; &amp;nbsp;1&amp;nbsp; 0&lt;BR /&gt;2&amp;nbsp; &amp;nbsp;2019&amp;nbsp; &amp;nbsp;0&amp;nbsp; 1&lt;BR /&gt;3&amp;nbsp; &amp;nbsp;2019&amp;nbsp; &amp;nbsp;1&amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;(for ID=1 year in first row is not 2017 so Ind=0&lt;/P&gt;
&lt;P&gt;for ID=2 year in first row is&amp;nbsp; 2017 so Ind=1&lt;/P&gt;
&lt;P&gt;for ID=3 year in first row is&amp;nbsp; 2017 so Ind=1)&lt;/P&gt;
&lt;P&gt;Why in my code I don't get the desired output??&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   data aaa;&lt;BR /&gt;input id date status;&lt;BR /&gt;cards;&lt;BR /&gt;1 2018 1&lt;BR /&gt;1 2019 1&lt;BR /&gt;2 2017 0&lt;BR /&gt;2 2018 0&lt;BR /&gt;2 2019 0&lt;BR /&gt;3 2017 0&lt;BR /&gt;3 2018 0&lt;BR /&gt;3 2019 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data bbb;&lt;BR /&gt;set aaa;&lt;BR /&gt;by id;&lt;BR /&gt;retain IndBase;&lt;BR /&gt;if first.id and date=2017 then IndBase=1;&lt;BR /&gt;else IndBase=0;&lt;BR /&gt;if last.id then output;&lt;BR /&gt;run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Oct 2019 11:00:44 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2019-10-16T11:00:44Z</dc:date>
    <item>
      <title>check if customer exist in basic  year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596811#M171897</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;For each customer (ID) there are multiple rows.&lt;/P&gt;
&lt;P&gt;Target: have one row for each customer with the original raw data in the last raw&amp;nbsp; and create a new field called "Ind" that get value 1 if year in first row for customer=2017 and 0 otherwise.&lt;/P&gt;
&lt;P&gt;I expect to get following output table:&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp;2019&amp;nbsp; &amp;nbsp;1&amp;nbsp; 0&lt;BR /&gt;2&amp;nbsp; &amp;nbsp;2019&amp;nbsp; &amp;nbsp;0&amp;nbsp; 1&lt;BR /&gt;3&amp;nbsp; &amp;nbsp;2019&amp;nbsp; &amp;nbsp;1&amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;(for ID=1 year in first row is not 2017 so Ind=0&lt;/P&gt;
&lt;P&gt;for ID=2 year in first row is&amp;nbsp; 2017 so Ind=1&lt;/P&gt;
&lt;P&gt;for ID=3 year in first row is&amp;nbsp; 2017 so Ind=1)&lt;/P&gt;
&lt;P&gt;Why in my code I don't get the desired output??&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   data aaa;&lt;BR /&gt;input id date status;&lt;BR /&gt;cards;&lt;BR /&gt;1 2018 1&lt;BR /&gt;1 2019 1&lt;BR /&gt;2 2017 0&lt;BR /&gt;2 2018 0&lt;BR /&gt;2 2019 0&lt;BR /&gt;3 2017 0&lt;BR /&gt;3 2018 0&lt;BR /&gt;3 2019 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data bbb;&lt;BR /&gt;set aaa;&lt;BR /&gt;by id;&lt;BR /&gt;retain IndBase;&lt;BR /&gt;if first.id and date=2017 then IndBase=1;&lt;BR /&gt;else IndBase=0;&lt;BR /&gt;if last.id then output;&lt;BR /&gt;run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 11:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596811#M171897</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-10-16T11:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: check if customer exist in basic  year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596812#M171898</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;please post your data in a usable form. The data step with aaa yields an error.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 11:02:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596812#M171898</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-16T11:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: check if customer exist in basic  year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596832#M171901</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data step you've posted is not working and the data bit under CARDS doesn't match your input statement (so couldn't fix it for you).&lt;/P&gt;
&lt;P&gt;Please post a working and tested SAS data step which creates useful sample data.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 11:36:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596832#M171901</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-10-16T11:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: check if customer exist in basic  year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596850#M171910</link>
      <description>I am not near computer now but i don't  understand  whst is wrong.Maybe change namneof field date to ddate.&lt;BR /&gt;Data is very simple and contain 3 fields.&lt;BR /&gt;</description>
      <pubDate>Wed, 16 Oct 2019 12:43:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596850#M171910</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-10-16T12:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: check if customer exist in basic  year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596851#M171911</link>
      <description>&lt;BR /&gt;I am not near computer now but i don't understand whst is wrong.Maybe change name of field date to ddate.&lt;BR /&gt;Data is very simple and contain 3 fields.</description>
      <pubDate>Wed, 16 Oct 2019 12:44:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596851#M171911</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-10-16T12:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: check if customer exist in basic  year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596853#M171912</link>
      <description>&lt;P&gt;There you go. Btw your posted result data is different from the description.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data aaa;
input id date status;
cards;
1 2018 1
1 2019 1
2 2017 0
2 2018 0
2 2019 0
3 2017 0
3 2018 0
3 2019 1
;

data bbb;
    set aaa;
    by id;
    if first.id then ind=ifn(date=2017, 1, 0);
    if last.id;
    retain ind;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;id  date    status  ind
1	2019	1	    0
2	2019	0	    1
3	2019	1	    1&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Oct 2019 12:52:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596853#M171912</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-16T12:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: check if customer exist in basic  year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596854#M171913</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;I am not near computer now but i don't understand whst is wrong.Maybe change name of field date to ddate.&lt;BR /&gt;Data is very simple and contain 3 fields.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Look at what you've posted. The code is all on one line. But even if I'm nice and split this over multiple lines I only get data for the first two columns (except for the first row; and the last row of data also looks wrong).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data aaa;
  input id date status;
  cards;
1 2018 11 
2019 12 
2017 02 
2018 02 
2019 03 
2017 03 
2018 03 
2019 1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kudos for&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;who apparently was able to decipher what you've posted&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 12:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596854#M171913</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-10-16T12:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: check if customer exist in basic  year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596857#M171914</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;, One of my greater achievements &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 13:00:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596857#M171914</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-16T13:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: check if customer exist in basic  year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596859#M171915</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;For each customer (ID) there are multiple rows.&lt;/P&gt;
&lt;P&gt;Target: have one row for each customer with the original raw data in the last raw&amp;nbsp; and create a new field called "Ind" that get value 1 if year in first row for customer=2017 and 0 otherwise.&lt;/P&gt;
&lt;P&gt;I expect to get following output table:&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp;2019&amp;nbsp; &amp;nbsp;1&amp;nbsp; 0&lt;BR /&gt;2&amp;nbsp; &amp;nbsp;2019&amp;nbsp; &amp;nbsp;0&amp;nbsp; 1&lt;BR /&gt;3&amp;nbsp; &amp;nbsp;2019&amp;nbsp; &amp;nbsp;1&amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;(for ID=1 year in first row is not 2017 so Ind=0&lt;/P&gt;
&lt;P&gt;for ID=2 year in first row is&amp;nbsp; 2017 so Ind=1&lt;/P&gt;
&lt;P&gt;for ID=3 year in first row is&amp;nbsp; 2017 so Ind=1)&lt;/P&gt;
&lt;P&gt;Why in my code I don't get the desired output??&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   data aaa;&lt;BR /&gt;input id date status;&lt;BR /&gt;cards;&lt;BR /&gt;1 2018 1&lt;BR /&gt;1 2019 1&lt;BR /&gt;2 2017 0&lt;BR /&gt;2 2018 0&lt;BR /&gt;2 2019 0&lt;BR /&gt;3 2017 0&lt;BR /&gt;3 2018 0&lt;BR /&gt;3 2019 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data bbb;&lt;BR /&gt;set aaa;&lt;BR /&gt;by id;&lt;BR /&gt;retain IndBase;&lt;BR /&gt;if first.id and date=2017 then IndBase=1;&lt;BR /&gt;else IndBase=0;&lt;BR /&gt;if last.id then output;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;[It's interesting that the "one-line code" is displayed nicely when you quote it. EDIT: But only while you're editing!]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A logical error causes the incorrect results: The statement &lt;FONT face="courier new,courier"&gt;else IndBase=0;&lt;/FONT&gt; is executed for the second, third, ..., last observation of each ID (because the &lt;FONT face="courier new,courier"&gt;first.id&lt;/FONT&gt; criterion is not met) and thus overwrites the value of interest from the first observation of the ID. Just change the IF/THEN-ELSE statement to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if first.id then IndBase=(date=2017);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so that only one assignment statement for IndBase is executed per BY group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(Note that the &lt;FONT face="courier new,courier"&gt;Ind&lt;/FONT&gt; value for ID=3 in your sample output does not match the description.)&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 13:03:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596859#M171915</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-10-16T13:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: check if customer exist in basic  year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596969#M171976</link>
      <description>&lt;P&gt;Perfect and thank you so much.&lt;/P&gt;
&lt;P&gt;As I understand from you when I wrote the code:&lt;/P&gt;
&lt;P&gt;"If FIRST.ID and date=2017 then IND=1; else IND=0; "&lt;/P&gt;
&lt;P&gt;then&amp;nbsp; else Ind=0 apply on all rows and not only for first row of each ID.&lt;/P&gt;
&lt;P&gt;I didn't know that and was sure that else will work also on first row of each ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I saw your perfect solution to write:&lt;/P&gt;
&lt;P&gt;"IF First.ID then Ind=(date=2017);"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Will it be correct&amp;nbsp; (alternative equivalent way) to write:&lt;/P&gt;
&lt;P&gt;""If FIRST.ID and date=2017 then do;&lt;/P&gt;
&lt;P&gt;IND=1;&lt;/P&gt;
&lt;P&gt;else IND=0;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One more question please:&lt;/P&gt;
&lt;P&gt;Is location of retain statement important?&lt;/P&gt;
&lt;P&gt;As I know I should write&amp;nbsp; "Retain ID"&amp;nbsp; &amp;nbsp; before&amp;nbsp; &amp;nbsp;"If&amp;nbsp; first.ID....."?&lt;/P&gt;
&lt;P&gt;Can I also write it at the end? after last statement?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway SAS will do last statement at the end&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 15:55:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596969#M171976</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-10-16T15:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: check if customer exist in basic  year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596985#M171983</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;As I understand from you when I wrote the code:&lt;/P&gt;
&lt;P&gt;"If FIRST.ID and date=2017 then IND=1; else IND=0; "&lt;/P&gt;
&lt;P&gt;then&amp;nbsp; else Ind=0 apply on all rows and not only for first row of each ID.&lt;/P&gt;
&lt;P&gt;I didn't know that and was sure that else will work also on first row of each ID.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The statement in the ELSE branch is executed whenever the IF condition is not met. The condition &lt;FONT face="courier new,courier"&gt;FIRST.ID and date=2017&lt;/FONT&gt; cannot be met for observations after the first within an ID BY-group because &lt;FONT face="courier new,courier"&gt;FIRST.ID=0&lt;/FONT&gt; for these observations and &lt;FONT face="courier new,courier"&gt;0&lt;/FONT&gt; is false.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;Will it be correct&amp;nbsp; (alternative equivalent way) to write:&lt;/P&gt;
&lt;P&gt;""If FIRST.ID and date=2017 then do;&lt;/P&gt;
&lt;P&gt;IND=1;&lt;/P&gt;
&lt;P&gt;else IND=0;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;"&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, you can't put the ELSE statement into a DO-END block in the corresponding THEN branch. This would separate the "ELSE" from the corresponding "IF-THEN." An equivalent "long form" of my IF-THEN statement is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if first.id then do;
  if date=2017 then IndBase=1;
  else IndBase=0;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Is location of retain statement important?
&lt;P&gt;As I know I should write&amp;nbsp; "Retain ID"&amp;nbsp; &amp;nbsp; before&amp;nbsp; &amp;nbsp;"If&amp;nbsp; first.ID....."?&lt;/P&gt;
&lt;P&gt;Can I also write it at the end? after last statement?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Variable &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;ID&lt;/FONT&gt;&lt;/STRONG&gt; (contained in dataset &lt;FONT face="courier new,courier"&gt;aaa&lt;/FONT&gt;) is retained by virtue of the SET statement, there's no need to retain it explicitly. In your code the only purpose of the RETAIN statement for variable &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;IndBase&lt;/FONT&gt;&lt;/STRONG&gt; is to instruct the compiler not to reset the value of &lt;FONT face="courier new,courier"&gt;IndBase&lt;/FONT&gt; to missing after each iteration of the DATA step. This is independent of the position of the (declarative) RETAIN statement in the DATA step. So, yes, you could put it before the RUN statement or in virtually any other place between the DATA statement and the RUN statement.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 16:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596985#M171983</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-10-16T16:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: check if customer exist in basic  year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596991#M171987</link>
      <description>&lt;P&gt;Sorry. I wanted to ask about location of statement&amp;nbsp; "Retain IndBase"&lt;/P&gt;
&lt;P&gt;Should it be before "first.Id" statement" or after ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 17:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596991#M171987</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-10-16T17:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: check if customer exist in basic  year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596998#M171989</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sorry. I wanted to ask about location of statement&amp;nbsp; "Retain IndBase"&lt;/P&gt;
&lt;P&gt;Should it be before "first.Id" statement" or after ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As mentioned, you may put it virtually anywhere. It's fine to leave it before the first IF statement, but you can move it after that statement as well (so that someone reading the code first sees the definition of &lt;FONT face="courier new,courier"&gt;IndBase&lt;/FONT&gt; in the assignment statement and &lt;EM&gt;then&lt;/EM&gt; learns that this [apparently] new variable will be retained).&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 17:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/check-if-customer-exist-in-basic-year/m-p/596998#M171989</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-10-16T17:30:45Z</dc:date>
    </item>
  </channel>
</rss>

