<?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 variable to be created with distinct Values during each Weekly execution i.e. it should not repeat in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/variable-to-be-created-with-distinct-Values-during-each-Weekly/m-p/675007#M203308</link>
    <description>&lt;P&gt;A variable is to be created that contains unique values like 00001,00002 etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now if all the unique values are assigned during execution, the value should not repeat when the code executes during next week execution. It should repeat only for cases where the key variable like member is same else it should assign different value from all previously assigned values. So how can we monitor all previously assigned values and if the member is same we assign same value else we assign different value for all future executions&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data First_Execution;&lt;BR /&gt;input memberid 8.;&lt;BR /&gt;datalines;&lt;BR /&gt;1001&lt;BR /&gt;1002&lt;BR /&gt;1003&lt;BR /&gt;1004&lt;BR /&gt;1005&lt;BR /&gt;1006&lt;BR /&gt;1007&lt;BR /&gt;1008&lt;BR /&gt;1009&lt;BR /&gt;1010&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data First_Execution_1;&lt;BR /&gt;set First_Execution;&lt;BR /&gt;FORMAT Source_ID $13.;&lt;BR /&gt;Source_ID= cats("777",put(_N_,z7.)) ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data Next_Execution;&lt;BR /&gt;input memberid 8.;&lt;BR /&gt;datalines;&lt;BR /&gt;1001&lt;BR /&gt;1002&lt;BR /&gt;1012&lt;BR /&gt;1004&lt;BR /&gt;1005&lt;BR /&gt;1011&lt;BR /&gt;1013&lt;BR /&gt;1015&lt;BR /&gt;1009&lt;BR /&gt;1015&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;data Next_Execution_1;&lt;BR /&gt;set Next_Execution;&lt;BR /&gt;FORMAT Source_ID $13.;&lt;BR /&gt;Source_ID= cats("777",put(_N_,z7.)) ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;During next execution if the member is present in the previous execution source ID will be same, else it will be different. So how should we create a base of all previous executions and store this information.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Aug 2020 15:43:06 GMT</pubDate>
    <dc:creator>nishant77goel</dc:creator>
    <dc:date>2020-08-06T15:43:06Z</dc:date>
    <item>
      <title>variable to be created with distinct Values during each Weekly execution i.e. it should not repeat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-to-be-created-with-distinct-Values-during-each-Weekly/m-p/675007#M203308</link>
      <description>&lt;P&gt;A variable is to be created that contains unique values like 00001,00002 etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now if all the unique values are assigned during execution, the value should not repeat when the code executes during next week execution. It should repeat only for cases where the key variable like member is same else it should assign different value from all previously assigned values. So how can we monitor all previously assigned values and if the member is same we assign same value else we assign different value for all future executions&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data First_Execution;&lt;BR /&gt;input memberid 8.;&lt;BR /&gt;datalines;&lt;BR /&gt;1001&lt;BR /&gt;1002&lt;BR /&gt;1003&lt;BR /&gt;1004&lt;BR /&gt;1005&lt;BR /&gt;1006&lt;BR /&gt;1007&lt;BR /&gt;1008&lt;BR /&gt;1009&lt;BR /&gt;1010&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data First_Execution_1;&lt;BR /&gt;set First_Execution;&lt;BR /&gt;FORMAT Source_ID $13.;&lt;BR /&gt;Source_ID= cats("777",put(_N_,z7.)) ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data Next_Execution;&lt;BR /&gt;input memberid 8.;&lt;BR /&gt;datalines;&lt;BR /&gt;1001&lt;BR /&gt;1002&lt;BR /&gt;1012&lt;BR /&gt;1004&lt;BR /&gt;1005&lt;BR /&gt;1011&lt;BR /&gt;1013&lt;BR /&gt;1015&lt;BR /&gt;1009&lt;BR /&gt;1015&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;data Next_Execution_1;&lt;BR /&gt;set Next_Execution;&lt;BR /&gt;FORMAT Source_ID $13.;&lt;BR /&gt;Source_ID= cats("777",put(_N_,z7.)) ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;During next execution if the member is present in the previous execution source ID will be same, else it will be different. So how should we create a base of all previous executions and store this information.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 15:43:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-to-be-created-with-distinct-Values-during-each-Weekly/m-p/675007#M203308</guid>
      <dc:creator>nishant77goel</dc:creator>
      <dc:date>2020-08-06T15:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: Need Suggestions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-to-be-created-with-distinct-Values-during-each-Weekly/m-p/675019#M203315</link>
      <description>&lt;P&gt;You will get more responses if you provide a meaningful subject line which describes the actual problem.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 14:42:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-to-be-created-with-distinct-Values-during-each-Weekly/m-p/675019#M203315</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-08-06T14:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Need Suggestions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-to-be-created-with-distinct-Values-during-each-Weekly/m-p/675029#M203320</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You will get more responses if you provide a meaningful subject line which describes the actual problem.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I have read the problem description and still don't grasp the exact nature of the task.&amp;nbsp; Sample data please.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 15:07:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-to-be-created-with-distinct-Values-during-each-Weekly/m-p/675029#M203320</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-08-06T15:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: variable to be created with distinct Values during each Weekly execution i.e. it should not repe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-to-be-created-with-distinct-Values-during-each-Weekly/m-p/675032#M203322</link>
      <description>&lt;P&gt;So you already have a unique member id, but want to map that to a different key, probably for anonymisation purposes?&lt;/P&gt;
&lt;P&gt;Please supply examples for your existing keys, &lt;U&gt;in a data step with datalines&lt;/U&gt;, so we have something to build upon.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 15:29:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-to-be-created-with-distinct-Values-during-each-Weekly/m-p/675032#M203322</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-06T15:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: variable to be created with distinct Values during each Weekly execution i.e. it should not repe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-to-be-created-with-distinct-Values-during-each-Weekly/m-p/675042#M203329</link>
      <description>Added in the description section. Please check. Thanks for all your help!</description>
      <pubDate>Thu, 06 Aug 2020 15:59:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-to-be-created-with-distinct-Values-during-each-Weekly/m-p/675042#M203329</guid>
      <dc:creator>nishant77goel</dc:creator>
      <dc:date>2020-08-06T15:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: variable to be created with distinct Values during each Weekly execution i.e. it should not repe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-to-be-created-with-distinct-Values-during-each-Weekly/m-p/675058#M203339</link>
      <description>&lt;P&gt;See this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data First_Execution;
input memberid 8.;
datalines;
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
;

data First_Execution_1;
set First_Execution;
FORMAT Source_ID $13.;
Source_ID= cats("777",put(_N_,z7.)) ;
run;

data Next_Execution;
input memberid 8.;
datalines;
1001
1002
1012
1004
1005
1011
1013
1015
1009
1015
;

data next_execution_1;
set next_execution end=done;
FORMAT Source_ID $13.;
if _n_ = 1
then do;
  declare hash l (dataset:"first_execution_1");
  l.definekey('memberid');
  l.definedata('memberid','source_id');
  l.definedone();
  declare hash k (dataset:"first_execution_1");
  k.definekey("source_id");
  k.definedone();
end;
if l.find() ne 0
then do;
  source_id = cats("777",put(_N_,z7.));
  do until (k.check() ne 0);
    _n_ = _n_ + 1;
    source_id = cats("777",put(_N_,z7.));
  end;
  rc = l.add();
  rc = k.add();
end;
if done
then do;
  rc = l.output(dataset:"first_execution_2");
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once you are satisfied that the method works, you can change the dataset name in the output() method so that the lookup dataset is always overwritten and therefore current.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 16:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-to-be-created-with-distinct-Values-during-each-Weekly/m-p/675058#M203339</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-06T16:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: variable to be created with distinct Values during each Weekly execution i.e. it should not repe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-to-be-created-with-distinct-Values-during-each-Weekly/m-p/675170#M203390</link>
      <description>&lt;P&gt;Thanks for your help! I am new to Hash programming so will take time for me to understand this code, but it is perfectly doing what is needed&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 01:05:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-to-be-created-with-distinct-Values-during-each-Weekly/m-p/675170#M203390</guid>
      <dc:creator>nishant77goel</dc:creator>
      <dc:date>2020-08-07T01:05:37Z</dc:date>
    </item>
  </channel>
</rss>

