<?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: While running this code error coming in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806764#M317926</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/378510"&gt;@aanan1417&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;error : undeclared key symbol prodtype for hash object at line 31 column 3.&lt;BR /&gt;error : data step component object failure. aborted during the execution phase&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That means you never defined the variable PRODTYPE in the data step.&lt;/P&gt;
&lt;P&gt;When you setup the hash object definition with DEFINEKEY() and DEFINEDATA() you are just passing in a string with the NAME of the variable.&amp;nbsp; When the hash actually begins to run those variables need to exist.&amp;nbsp; But PRODTYPE is not in the input dataset&amp;nbsp;&lt;STRONG&gt;gxhi1&lt;/STRONG&gt; and there is no other code in the data step to create it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your CHECK() function call will not work either if there is no such variable.&amp;nbsp; If you want to use a different variable in the CHECK() call then specify the KEY value to use in the function call.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Apr 2022 13:29:51 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-04-08T13:29:51Z</dc:date>
    <item>
      <title>While running this code error coming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806696#M317875</link>
      <description>&lt;LI-CODE lang="sas"&gt;data gxhi2;
set gxhi1;
if _n_ = 1
then do;
  declare hash p (dataset:"prod_pol_mapping (keep=product_type rename=(product_type=prodtype))");
  p.definekey("prodtype");
  p.definedata("prodtype");
  p.definedone();
end;
if p.check() = 0;
run;&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 08 Apr 2022 05:43:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806696#M317875</guid>
      <dc:creator>aanan1417</dc:creator>
      <dc:date>2022-04-08T05:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: While running this code error coming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806697#M317876</link>
      <description>error : undeclared key symbol prodtype for hash object at line 31 column 3.&lt;BR /&gt;error : data step component  object failure. aborted during the execution phase</description>
      <pubDate>Fri, 08 Apr 2022 05:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806697#M317876</guid>
      <dc:creator>aanan1417</dc:creator>
      <dc:date>2022-04-08T05:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: While running this code error coming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806698#M317877</link>
      <description>&lt;P&gt;Please post the complete log (including all code and messages).&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 05:49:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806698#M317877</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-08T05:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: While running this code error coming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806702#M317880</link>
      <description>1                                                          The SAS System                                10:36 Friday, April 8, 2022&lt;BR /&gt;&lt;BR /&gt;1          ;*';*";*/;quit;run;&lt;BR /&gt;2          OPTIONS PAGENO=MIN;&lt;BR /&gt;3          %LET _CLIENTTASKLABEL='Program';&lt;BR /&gt;4          %LET _CLIENTPROJECTPATH='';&lt;BR /&gt;5          %LET _CLIENTPROJECTNAME='';&lt;BR /&gt;6          %LET _SASPROGRAMFILE=;&lt;BR /&gt;7          &lt;BR /&gt;8          ODS _ALL_ CLOSE;&lt;BR /&gt;9          OPTIONS DEV=ACTIVEX;&lt;BR /&gt;10         GOPTIONS XPIXELS=0 YPIXELS=0;&lt;BR /&gt;11         FILENAME EGSR TEMP;&lt;BR /&gt;12         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR&lt;BR /&gt;13             STYLE=HtmlBlue&lt;BR /&gt;14             STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")&lt;BR /&gt;15             NOGTITLE&lt;BR /&gt;16             NOGFOOTNOTE&lt;BR /&gt;17             GPATH=&amp;amp;sasworklocation&lt;BR /&gt;18             ENCODING=UTF8&lt;BR /&gt;19             options(rolap="on")&lt;BR /&gt;20         ;&lt;BR /&gt;NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR&lt;BR /&gt;21         &lt;BR /&gt;22         GOPTIONS ACCESSIBLE;&lt;BR /&gt;23         &lt;BR /&gt;24            proc sql ;&lt;BR /&gt;25         create table gxhi as&lt;BR /&gt;26         select distinct(CHDRNUM) as Policy_no&lt;BR /&gt;27                ,SUMINSU&lt;BR /&gt;28                            ,EFFDATE&lt;BR /&gt;29                            ,PRODTYP&lt;BR /&gt;30                            ,XCESSSI&lt;BR /&gt;31         from SAS0416.GXHI_&amp;amp;yr&amp;amp;mon&lt;BR /&gt;32         where DTETRM ne EFFDATE&lt;BR /&gt;33         order by Policy_no, PRODTYP , EFFDATE desc;&lt;BR /&gt;NOTE: Table WORK.GXHI created, with 40384382 rows and 5 columns.&lt;BR /&gt;&lt;BR /&gt;34         &lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;      real time           1:07.09&lt;BR /&gt;      cpu time            1:39.03&lt;BR /&gt;      &lt;BR /&gt;35         data gxhi1;&lt;BR /&gt;&lt;BR /&gt;36         set gxhi;&lt;BR /&gt;37             PRODTYP1 = input(PRODTYP, best32.);&lt;BR /&gt;38                         drop PRODTYP;&lt;BR /&gt;39                         rename PRODTYP1=PRODTYP;&lt;BR /&gt;40         &lt;BR /&gt;41         run;&lt;BR /&gt;&lt;BR /&gt;NOTE: There were 40384382 observations read from the data set WORK.GXHI.&lt;BR /&gt;NOTE: The data set WORK.GXHI1 has 40384382 observations and 5 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;      real time           7.03 seconds&lt;BR /&gt;      cpu time            6.98 seconds&lt;BR /&gt;      &lt;BR /&gt;&lt;BR /&gt;42         &lt;BR /&gt;2                                                          The SAS System                                10:36 Friday, April 8, 2022&lt;BR /&gt;&lt;BR /&gt;43         data PROD_POL_MAPPING;&lt;BR /&gt;44         set sas0416.PROD_POL_MAPPING;&lt;BR /&gt;45         run;&lt;BR /&gt;&lt;BR /&gt;NOTE: There were 140 observations read from the data set SAS0416.PROD_POL_MAPPING.&lt;BR /&gt;NOTE: The data set WORK.PROD_POL_MAPPING has 140 observations and 3 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;      real time           0.03 seconds&lt;BR /&gt;      cpu time            0.01 seconds&lt;BR /&gt;      &lt;BR /&gt;&lt;BR /&gt;46         &lt;BR /&gt;47         data gxhi2; /* create this new dataset */&lt;BR /&gt;48         set gxhi1; /* read all variables from this dataset */&lt;BR /&gt;49         if _n_ = 1 /* in the first iteration of the data step */&lt;BR /&gt;50         then do;&lt;BR /&gt;51           /* define a hash object */&lt;BR /&gt;52           declare hash p (dataset:"prod_pol_mapping (keep=product_type rename=(product_type=prodtype))");&lt;BR /&gt;53           /* define the object from a dataset where we keep one variable and rename it, so the names fit */&lt;BR /&gt;54           p.definekey("prodtype"); /* define the single variable as key */&lt;BR /&gt;55           p.definedata("prodtype"); /* and also as data, this reduces the memory footprint of the object */&lt;BR /&gt;56           p.definedone(); /* definition complete */&lt;BR /&gt;57         end;&lt;BR /&gt;58         if p.check() = 0; /* the check method returns a zero when an entry is found */&lt;BR /&gt;59         run;&lt;BR /&gt;&lt;BR /&gt;ERROR: Undeclared key symbol prodtype for hash object at line 56 column 3.&lt;BR /&gt;ERROR: DATA STEP Component Object failure.  Aborted during the EXECUTION phase.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: There were 1 observations read from the data set WORK.GXHI1.&lt;BR /&gt;WARNING: The data set WORK.GXHI2 may be incomplete.  When this step was stopped there were 0 observations and 5 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;      real time           0.04 seconds&lt;BR /&gt;      cpu time            0.03 seconds</description>
      <pubDate>Fri, 08 Apr 2022 06:23:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806702#M317880</guid>
      <dc:creator>aanan1417</dc:creator>
      <dc:date>2022-04-08T06:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: While running this code error coming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806712#M317888</link>
      <description>&lt;P&gt;I made a mistake in naming the variable. It should be prodtyp instead of prodtype. Please change that wherever it appears.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Background: since a variable named prodtype has never been defined in the PDV before the hash definition, it can't be used at this point (hash definition happens during runtime, and then no variables can be added to the PDV). If one needs to create new variables through a hash, they must be defined first (usually with a LENGTH statement), but here I use an existing variable coming in from the SET, and the name must match properly.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 07:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806712#M317888</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-08T07:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: While running this code error coming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806750#M317917</link>
      <description>&lt;PRE&gt;data gxhi2;
set gxhi1;
if _n_ = 1
then do;

&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;if 0 then set prod_pol_mapping (keep=product_type rename=(product_type=prodtype)) ;&lt;/STRONG&gt;&lt;/FONT&gt;

  declare hash p (dataset:"prod_pol_mapping (keep=product_type rename=(product_type=prodtype))");
  p.definekey("prodtype");
  p.definedata("prodtype");
  p.definedone();
end;
if p.check() = 0;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Apr 2022 12:41:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806750#M317917</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-04-08T12:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: While running this code error coming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806764#M317926</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/378510"&gt;@aanan1417&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;error : undeclared key symbol prodtype for hash object at line 31 column 3.&lt;BR /&gt;error : data step component object failure. aborted during the execution phase&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That means you never defined the variable PRODTYPE in the data step.&lt;/P&gt;
&lt;P&gt;When you setup the hash object definition with DEFINEKEY() and DEFINEDATA() you are just passing in a string with the NAME of the variable.&amp;nbsp; When the hash actually begins to run those variables need to exist.&amp;nbsp; But PRODTYPE is not in the input dataset&amp;nbsp;&lt;STRONG&gt;gxhi1&lt;/STRONG&gt; and there is no other code in the data step to create it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your CHECK() function call will not work either if there is no such variable.&amp;nbsp; If you want to use a different variable in the CHECK() call then specify the KEY value to use in the function call.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 13:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806764#M317926</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-08T13:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: While running this code error coming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806765#M317927</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;the mistake was by me, posted in another thread. Somehow the back of my mind translated the (most possibly German) abbreviation prodtyp to the English prodtype. Using prodtyp instead of prodtype in the RENAME= and DEFINE statements will fix it, as that variable is defined through the dataset in the SET statement.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 13:33:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/While-running-this-code-error-coming/m-p/806765#M317927</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-08T13:33:36Z</dc:date>
    </item>
  </channel>
</rss>

