<?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: Data step with zero observations and hash function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-step-with-zero-observations-and-hash-function/m-p/522056#M141685</link>
    <description>&lt;P&gt;&lt;EM&gt;create a macro variable with zero as count if the source key dataset is empty&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Just add&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    call symput('sas_stac_cnt','0');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;before the SET statement.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Dec 2018 22:56:02 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2018-12-17T22:56:02Z</dc:date>
    <item>
      <title>Data step with zero observations and hash function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-with-zero-observations-and-hash-function/m-p/521944#M141654</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use has as a look up table to join two tables. My issues is i will get data from the source table only once in four days. For other days the table will have zero records. Because of this reason I am not able use this code since my macro count variables wont be created for data set with zero records since the logic wont enter the do until loop. Can u help me with a logic so that i can join the tables if the data exists or create a macro variable with zero as count if the source key dataset is empty&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.sasgrid_extract(drop= rc tot_cnt);&lt;BR /&gt;set work.source_key_extract ;&lt;BR /&gt;&lt;BR /&gt;declare hash stac (dataset: 'work.source_key_extract');&lt;BR /&gt;stac.definekey('acct');&lt;BR /&gt;stac.definedone();&lt;BR /&gt;do until(eof);&lt;BR /&gt;set vp.account_table (keep = acct&lt;BR /&gt;amount&lt;BR /&gt;type&lt;BR /&gt;code&lt;BR /&gt;flag&lt;BR /&gt;date&lt;BR /&gt;&lt;BR /&gt;) end=eof ;&lt;BR /&gt;rc = stac.find();&lt;BR /&gt;if rc eq 0 then do;&lt;BR /&gt;sas_acct = acct;&lt;BR /&gt;tot_cnt+1;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;call symputx("sas_stac_cnt",tot_cnt);&lt;BR /&gt;end;&lt;BR /&gt;stop;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 15:19:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-with-zero-observations-and-hash-function/m-p/521944#M141654</guid>
      <dc:creator>Jagadeesh2907</dc:creator>
      <dc:date>2018-12-17T15:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: Data step with zero observations and hash function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-with-zero-observations-and-hash-function/m-p/521984#M141661</link>
      <description>&lt;P&gt;Just code your step so that it does try to read past the end of the input dataset.&lt;/P&gt;
&lt;P&gt;It looks like you are not really using that first SET statement to read the data (that is being done later) so make it impossible to execute.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if 0 then set work.source_key_extract ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then SAS will not try to read past the end when it is empty.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 17:42:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-with-zero-observations-and-hash-function/m-p/521984#M141661</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-12-17T17:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: Data step with zero observations and hash function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-with-zero-observations-and-hash-function/m-p/522056#M141685</link>
      <description>&lt;P&gt;&lt;EM&gt;create a macro variable with zero as count if the source key dataset is empty&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Just add&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    call symput('sas_stac_cnt','0');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;before the SET statement.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 22:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-with-zero-observations-and-hash-function/m-p/522056#M141685</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-12-17T22:56:02Z</dc:date>
    </item>
  </channel>
</rss>

