<?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: Merge data sets using Hash method in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893099#M352796</link>
    <description>&lt;P&gt;IF 0 means that the following statement will never be&amp;nbsp;&lt;EM&gt;executed&lt;/EM&gt; at runtime, but during compilation the data step compiler will read the dataset metadata and include the variables in the PDV.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I would insert the statement immediately after the unconditional SET, for clarity.&lt;/P&gt;</description>
    <pubDate>Thu, 07 Sep 2023 08:14:47 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-09-07T08:14:47Z</dc:date>
    <item>
      <title>Merge data sets using Hash method</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893086#M352786</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to ask about Merge using Hash method.&lt;/P&gt;
&lt;P&gt;I receive an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Data tbl1;
Format date date9.;
Input Name$ date :date9. Amnt1;
cards;
A 01JAN2023 100
A 02JAN2023 150
A 03JAN2023 200
A 04JAN2023 250
B 02JAN2023 200
B 04JAN2023 300
B 06JAN2023 400
C 03JAN2023 300
C 08JAN2023 400
C 15JAN2023 500
;
run;

Data tbl2;
Input Name$ numerator W;
cards;
A 111 1000
B 222 2000
C 333 3000
D 444 4000
;
run;

/***Way1***/
proc sort data = tbl1;
by Name;
run;
proc sort data = tbl2;
by Name;
run;
data Way1;      
merge tbl1 (in=a) tbl2(in=b);
by Name;
IF a and b;
run;


/***Way2***/
data Way2;
set tbl1;
if _n_ = 1
then do;
declare hash tbl2 (dataset:"tbl2 (keep=Name numerator)");
tbl2.definekey("Name");
tbl2.definedata("numerator");
tbl2.definedone();
call missing("numerator");
end;
rc = tbl2.find();
drop rc;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the error&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1                                                          The SAS System                          07:19 Thursday, September 7, 2023

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Program (2)';
4          %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5          %LET _CLIENTPROJECTPATH='';
6          %LET _CLIENTPROJECTPATHHOST='';
7          %LET _CLIENTPROJECTNAME='';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=PNG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         FILENAME EGSR TEMP;
15         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16             STYLE=HTMLBlue
17             STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HTMLBlue.css")
18             NOGTITLE
19             NOGFOOTNOTE
20             GPATH=&amp;amp;sasworklocation
21             ENCODING=UTF8
22             options(rolap="on")
23         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24         
25         GOPTIONS ACCESSIBLE;
26         /***Way2***/
27         data Way2;
28         set tbl1;
29         if _n_ = 1
30         then do;
31         declare hash tbl2 (dataset:"tbl2 (keep=Name numerator)");
32         tbl2.definekey("Name");
33         tbl2.definedata("numerator");
34         tbl2.definedone();
35         call missing("numerator");
                        ___________
                        135
ERROR 135-185: Attempt to change the value of the constant "numerator" in the MISSING subroutine call.

36         end;
37         rc = tbl2.find();
38         drop rc;
39         run;

NOTE: Compression was disabled for data set WORK.WAY2 because compression overhead would increase the size of the data set.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.WAY2 may be incomplete.  When this step was stopped there were 0 observations and 3 variables.
WARNING: Data set WORK.WAY2 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      memory              546.93k
      OS Memory           25768.00k
      Timestamp           09/07/2023 09:40:49 AM
      Step Count                        131  Switch Count  0
      Page Faults                       0
2                                                          The SAS System                          07:19 Thursday, September 7, 2023

      Page Reclaims                     34
      Page Swaps                        0
      Voluntary Context Switches        15
      Involuntary Context Switches      0
      Block Input Operations            0
      Block Output Operations           0
      

40         
41         
42         GOPTIONS NOACCESSIBLE;
43         %LET _CLIENTTASKLABEL=;
44         %LET _CLIENTPROCESSFLOWNAME=;
45         %LET _CLIENTPROJECTPATH=;
46         %LET _CLIENTPROJECTPATHHOST=;
47         %LET _CLIENTPROJECTNAME=;
48         %LET _SASPROGRAMFILE=;
49         %LET _SASPROGRAMFILEHOST=;
50         
51         ;*';*";*/;quit;run;
52         ODS _ALL_ CLOSE;
53         
54         
55         QUIT; RUN;
56         
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Here is the error&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1                                                          The SAS System                          07:19 Thursday, September 7, 2023

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Program (2)';
4          %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5          %LET _CLIENTPROJECTPATH='';
6          %LET _CLIENTPROJECTPATHHOST='';
7          %LET _CLIENTPROJECTNAME='';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=PNG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         FILENAME EGSR TEMP;
15         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16             STYLE=HTMLBlue
17             STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HTMLBlue.css")
18             NOGTITLE
19             NOGFOOTNOTE
20             GPATH=&amp;amp;sasworklocation
21             ENCODING=UTF8
22             options(rolap="on")
23         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24         
25         GOPTIONS ACCESSIBLE;
26         /***Way2***/
27         data Way2;
28         set tbl1;
29         if _n_ = 1
30         then do;
31         declare hash tbl2 (dataset:"tbl2 (keep=Name numerator)");
32         tbl2.definekey("Name");
33         tbl2.definedata("numerator");
34         tbl2.definedone();
35         call missing("numerator");
                        ___________
                        135
&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;ERROR 135-185: Attempt to change the value of the constant "numerator" in the MISSING subroutine call.&lt;/FONT&gt;&lt;/STRONG&gt;

36         end;
37         rc = tbl2.find();
38         drop rc;
39         run;

NOTE: Compression was disabled for data set WORK.WAY2 because compression overhead would increase the size of the data set.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.WAY2 may be incomplete.  When this step was stopped there were 0 observations and 3 variables.
WARNING: Data set WORK.WAY2 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      memory              546.93k
      OS Memory           25768.00k
      Timestamp           09/07/2023 09:40:49 AM
      Step Count                        131  Switch Count  0
      Page Faults                       0
2                                                          The SAS System                          07:19 Thursday, September 7, 2023

      Page Reclaims                     34
      Page Swaps                        0
      Voluntary Context Switches        15
      Involuntary Context Switches      0
      Block Input Operations            0
      Block Output Operations           0
      

40         
41         
42         GOPTIONS NOACCESSIBLE;
43         %LET _CLIENTTASKLABEL=;
44         %LET _CLIENTPROCESSFLOWNAME=;
45         %LET _CLIENTPROJECTPATH=;
46         %LET _CLIENTPROJECTPATHHOST=;
47         %LET _CLIENTPROJECTNAME=;
48         %LET _SASPROGRAMFILE=;
49         %LET _SASPROGRAMFILEHOST=;
50         
51         ;*';*";*/;quit;run;
52         ODS _ALL_ CLOSE;
53         
54         
55         QUIT; RUN;
56         
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 06:50:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893086#M352786</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-09-07T06:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Merge data sets using Hash method</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893087#M352787</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try removing the quotes from the call missing routine, so that it looks like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call missing(numerator);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 06:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893087#M352787</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2023-09-07T06:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: Merge data sets using Hash method</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893090#M352788</link>
      <description>&lt;P&gt;You do not properly define numerator; either use a LENGTH statement, or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if 0 then set tbl2 (keep=name numerator);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;at the beginning of the DATA step to get the variable into the PDV.&lt;/P&gt;
&lt;P&gt;The second method will automatically take care of attribute changes.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 07:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893090#M352788</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-09-07T07:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Merge data sets using Hash method</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893092#M352789</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;May you please show the full code?&lt;/P&gt;
&lt;P&gt;I tried this one&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Way2;
set tbl1;
if _n_ = 1
then do;
declare hash tbl2 (dataset:"tbl2 (keep=Name numerator)");
if 0 then set tbl2 (keep=name numerator);
tbl2.definekey("Name");
tbl2.definedata("numerator");
tbl2.definedone();
call missing("numerator");
end;
rc = tbl2.find();
drop rc;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Sep 2023 07:51:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893092#M352789</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-09-07T07:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Merge data sets using Hash method</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893094#M352791</link>
      <description>&lt;P&gt;CALL MISSING needs variables, not character literals, as already mentioned by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22588"&gt;@Amir&lt;/a&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 07:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893094#M352791</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-09-07T07:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Merge data sets using Hash method</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893097#M352794</link>
      <description>&lt;P&gt;Thanks,Now it is working &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;May you please show where should&amp;nbsp; write the sentence&amp;nbsp;if 0 then&amp;nbsp; ...?&lt;/P&gt;
&lt;P&gt;Is the sentence (if 0 then ) is alternative to call missing sentence?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set tbl1;
if _n_ = 1
then do;
declare hash tbl2 (dataset:"tbl2 (keep=Name numerator)");
tbl2.definekey("Name");
tbl2.definedata("numerator");
tbl2.definedone();
call missing(numerator);
end;
rc = tbl2.find();
drop rc;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Sep 2023 08:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893097#M352794</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-09-07T08:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Merge data sets using Hash method</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893099#M352796</link>
      <description>&lt;P&gt;IF 0 means that the following statement will never be&amp;nbsp;&lt;EM&gt;executed&lt;/EM&gt; at runtime, but during compilation the data step compiler will read the dataset metadata and include the variables in the PDV.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I would insert the statement immediately after the unconditional SET, for clarity.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 08:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893099#M352796</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-09-07T08:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Merge data sets using Hash method</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893100#M352797</link>
      <description>&lt;P&gt;May you please show how to apply it in the full code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 08:15:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893100#M352797</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-09-07T08:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Merge data sets using Hash method</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893129#M352820</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data way2;
set tbl1;
if 0 then set tbl2 (keep=name numerator);
if _n_ = 1
then do;
  declare hash tbl2 (dataset:"tbl2 (keep=Name numerator)");
  tbl2.definekey("Name");
  tbl2.definedata("numerator");
  tbl2.definedone();
  call missing(numerator);
end;
rc = tbl2.find();
drop rc;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Sep 2023 10:43:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-data-sets-using-Hash-method/m-p/893129#M352820</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-09-07T10:43:38Z</dc:date>
    </item>
  </channel>
</rss>

