<?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 Hash method to merge data set in permanent library in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Hash-method-to-merge-data-set-in-permanent-library/m-p/893101#M352798</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I am using Hash method to merge data sets.&lt;/P&gt;
&lt;P&gt;One of the data sets is in permanent library and then I get 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 r_r.tbl2;
Input Name$ numerator W;
cards;
A 111 1000
B 222 2000
C 333 3000
D 444 4000
;
run;


data want;
set tbl1;
if _n_ = 1
then do;
declare hash r_r.tbl2 (dataset:"r_r.tbl2 (keep=Name numerator)");
r_r.tbl2.definekey("Name");
r_r.tbl2.definedata("numerator");
r_r.tbl2.definedone();
call missing(numerator);
end;
rc = r_r.tbl2.find();
drop rc;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The error is :&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 (5)';
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 r_r.tbl2 (dataset:"r_r.tbl2 (keep=Name numerator)");
                        ________
                        22
                        76
32         r_r.tbl2.definekey("Name");
           __________________
           780
ERROR: DATA STEP Component Object failure.  Aborted during the COMPILATION phase.
ERROR 22-322: Expecting a name.  

ERROR 76-322: Syntax error, statement will be ignored.

ERROR 780-185: Invalid object or method name.

NOTE: The SAS System stopped processing this step because of errors.
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              390.43k
      OS Memory           25768.00k
      Timestamp           09/07/2023 11:13:33 AM
      Step Count                        156  Switch Count  0
      Page Faults                       0
      Page Reclaims                     28
      Page Swaps                        0
      Voluntary Context Switches        7
2                                                          The SAS System                          07:19 Thursday, September 7, 2023

      Involuntary Context Switches      0
      Block Input Operations            0
      Block Output Operations           0
      
33         r_r.tbl2.definedata("numerator");
34         r_r.tbl2.definedone();
35         call missing(numerator);
36         end;
37         rc = r_r.tbl2.find();
38         drop rc;
39         run;
40         
41         GOPTIONS NOACCESSIBLE;
42         %LET _CLIENTTASKLABEL=;
43         %LET _CLIENTPROCESSFLOWNAME=;
44         %LET _CLIENTPROJECTPATH=;
45         %LET _CLIENTPROJECTPATHHOST=;
46         %LET _CLIENTPROJECTNAME=;
47         %LET _SASPROGRAMFILE=;
48         %LET _SASPROGRAMFILEHOST=;
49         
50         ;*';*";*/;quit;run;
51         ODS _ALL_ CLOSE;
52         
53         
54         QUIT; RUN;
55         
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 07 Sep 2023 08:17:10 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2023-09-07T08:17:10Z</dc:date>
    <item>
      <title>Hash method to merge data set in permanent library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-method-to-merge-data-set-in-permanent-library/m-p/893101#M352798</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I am using Hash method to merge data sets.&lt;/P&gt;
&lt;P&gt;One of the data sets is in permanent library and then I get 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 r_r.tbl2;
Input Name$ numerator W;
cards;
A 111 1000
B 222 2000
C 333 3000
D 444 4000
;
run;


data want;
set tbl1;
if _n_ = 1
then do;
declare hash r_r.tbl2 (dataset:"r_r.tbl2 (keep=Name numerator)");
r_r.tbl2.definekey("Name");
r_r.tbl2.definedata("numerator");
r_r.tbl2.definedone();
call missing(numerator);
end;
rc = r_r.tbl2.find();
drop rc;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The error is :&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 (5)';
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 r_r.tbl2 (dataset:"r_r.tbl2 (keep=Name numerator)");
                        ________
                        22
                        76
32         r_r.tbl2.definekey("Name");
           __________________
           780
ERROR: DATA STEP Component Object failure.  Aborted during the COMPILATION phase.
ERROR 22-322: Expecting a name.  

ERROR 76-322: Syntax error, statement will be ignored.

ERROR 780-185: Invalid object or method name.

NOTE: The SAS System stopped processing this step because of errors.
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              390.43k
      OS Memory           25768.00k
      Timestamp           09/07/2023 11:13:33 AM
      Step Count                        156  Switch Count  0
      Page Faults                       0
      Page Reclaims                     28
      Page Swaps                        0
      Voluntary Context Switches        7
2                                                          The SAS System                          07:19 Thursday, September 7, 2023

      Involuntary Context Switches      0
      Block Input Operations            0
      Block Output Operations           0
      
33         r_r.tbl2.definedata("numerator");
34         r_r.tbl2.definedone();
35         call missing(numerator);
36         end;
37         rc = r_r.tbl2.find();
38         drop rc;
39         run;
40         
41         GOPTIONS NOACCESSIBLE;
42         %LET _CLIENTTASKLABEL=;
43         %LET _CLIENTPROCESSFLOWNAME=;
44         %LET _CLIENTPROJECTPATH=;
45         %LET _CLIENTPROJECTPATHHOST=;
46         %LET _CLIENTPROJECTNAME=;
47         %LET _SASPROGRAMFILE=;
48         %LET _SASPROGRAMFILEHOST=;
49         
50         ;*';*";*/;quit;run;
51         ODS _ALL_ CLOSE;
52         
53         
54         QUIT; RUN;
55         
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Sep 2023 08:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-method-to-merge-data-set-in-permanent-library/m-p/893101#M352798</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-09-07T08:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Hash method to merge data set in permanent library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-method-to-merge-data-set-in-permanent-library/m-p/893107#M352802</link>
      <description>&lt;P&gt;I'm no hash programmer, but you should not use the data sets qualified name as the hash object identifier, I think you only need to specify the dataset in dataset: "option".&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 08:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-method-to-merge-data-set-in-permanent-library/m-p/893107#M352802</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2023-09-07T08:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Hash method to merge data set in permanent library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-method-to-merge-data-set-in-permanent-library/m-p/893108#M352803</link>
      <description>&lt;P&gt;The compiler expects the name of a hash object, not a SAS data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See the code below. I added the &lt;STRONG&gt;&lt;EM&gt;if 0 then set &lt;/EM&gt;&lt;/STRONG&gt;Statement in case the numerator variable does not exist in the PDV in the first place.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set tbl1;
if _n_ = 1
then do;
declare hash h (dataset:"r_r.tbl2");
h.definekey("Name");
h.definedata("numerator");
h.definedone();
if 0 then set r_r.tbl2 (keep=Name numerator);
call missing(numerator);
end;
rc = h.find();
drop rc;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Sep 2023 08:52:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-method-to-merge-data-set-in-permanent-library/m-p/893108#M352803</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2023-09-07T08:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: Hash method to merge data set in permanent library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-method-to-merge-data-set-in-permanent-library/m-p/893116#M352810</link>
      <description>&lt;P&gt;Thanks, Sorry but I didn't understand which potential problem the statement IF 0 then should solve.&lt;/P&gt;
&lt;P&gt;In this example below don't have numerator column&amp;nbsp; in data set r_r.tbl2 , however there is an error&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 r_r.tbl2;
Input Name$  W;
cards;
A  1000
B  2000
C  3000
D  4000
;
run;


data want;
set tbl1;
if _n_ = 1
then do;
declare hash h (dataset:"r_r.tbl2");
h.definekey("Name");  /***Merge By VARS***/
h.definedata("numerator");/***Columns to select from r_r.tbl2***/
h.definedone();
if 0 then set r_r.tbl2 (keep=Name numerator);
/*I added the if 0 then set Statement in case the numerator variable does not exist in the PDV in the first place*/
call missing(numerator);
end;
rc = h.find();
drop rc;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Sep 2023 09:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-method-to-merge-data-set-in-permanent-library/m-p/893116#M352810</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-09-07T09:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Hash method to merge data set in permanent library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Hash-method-to-merge-data-set-in-permanent-library/m-p/893121#M352813</link>
      <description>&lt;P&gt;First off, you will definitely get an error because there is not variable called &lt;STRONG&gt;numerator&lt;/STRONG&gt; in your&amp;nbsp;&amp;nbsp;r_r.tbl2 sample data.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 10:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Hash-method-to-merge-data-set-in-permanent-library/m-p/893121#M352813</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2023-09-07T10:10:26Z</dc:date>
    </item>
  </channel>
</rss>

