<?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: Error:  Output data with zero observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-Output-data-with-zero-observations/m-p/574824#M162491</link>
    <description>&lt;P&gt;Thank you so much!!! Your suggestions worked!!!&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jul 2019 23:34:57 GMT</pubDate>
    <dc:creator>Anita3</dc:creator>
    <dc:date>2019-07-18T23:34:57Z</dc:date>
    <item>
      <title>Error:  Output data with zero observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Output-data-with-zero-observations/m-p/574810#M162480</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;Can someone help me decipher what is wrong with this code? The work dataset has about half a million observation but its not been outputted to the overlapped dataset as that always comes up as zero observation.&lt;BR /&gt;&lt;BR /&gt;Thank you for your help.&lt;BR /&gt;&lt;BR /&gt;Please see below code with associated error&lt;BR /&gt;&lt;BR /&gt;data Overlapped; set WORK.Final; by DE_id ondate; *type class ; retain typa typb;&lt;BR /&gt;if first.ondate then do; count=0; typa=0; typb=0; end;&lt;BR /&gt;if CLASS='OPIOID' then typa+1;&lt;BR /&gt;if CLASS='BENZO' then typb+1;&lt;BR /&gt;count+1;&lt;BR /&gt;if last.ondate and count gt 1 then do;&lt;BR /&gt;if typa and typb then do; olap='O&amp;amp;B'; output; end;&lt;BR /&gt;if typa gt 1 then do; olap='O'; output; end;&lt;BR /&gt;if typb gt 1 then do; olap='B'; output; end;&lt;BR /&gt;end;&lt;BR /&gt;drop CLASS typa typb;&lt;BR /&gt;&lt;BR /&gt;proc sort DATA= Overlapped; by DE_id olap ondate;&lt;BR /&gt;proc print DATA= Overlapped (OBS=10); id DE_id olap ondate;&lt;BR /&gt;title 'Collapse by date and type where multiple drugs taken'; run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ERROR CODE: ALL IN BLACK (NO RED)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;data Overlapped; set WORK.Final; by DE_id ondate; *type class ; retain typa typb;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;if first.ondate then do; count=0; typa=0; typb=0; end;&lt;BR /&gt;&lt;BR /&gt;if CLASS='OPIOID' then typa+1;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;if CLASS='BENZO' then typb+1;&lt;BR /&gt;&lt;BR /&gt;*count+1;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;if last.ondate and count gt 1 then do;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;if typa and typb then do; olap='O&amp;amp;B'; output; end;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;if typa gt 1 then do; olap='O'; output; end;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;if typb gt 1 then do; olap='B'; output; end;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;end;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;drop CLASS typa typb;&lt;BR /&gt;&lt;BR /&gt;NOTE: There were 54550121 observations read from the data set WORK.FINAL.&lt;BR /&gt;NOTE: The data set WORK.OVERLAPPED has 0 observations and 24 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 59.19 seconds&lt;BR /&gt;cpu time 16.32 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;proc sort DATA= Overlapped; by DE_id olap ondate;&lt;BR /&gt;&lt;BR /&gt;NOTE: Input data set is empty.&lt;BR /&gt;NOTE: The data set WORK.OVERLAPPED has 0 observations and 24 variables.&lt;BR /&gt;NOTE: PROCEDURE SORT used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;proc print DATA= Overlapped (OBS=10); id DE_id olap ondate;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;title 'Collapse by date and type where multiple drugs taken'; run;&lt;BR /&gt;NOTE: No observations in data set WORK.OVERLAPPED.&lt;BR /&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 21:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Output-data-with-zero-observations/m-p/574810#M162480</guid>
      <dc:creator>Anita3</dc:creator>
      <dc:date>2019-07-18T21:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Error:  Output data with zero observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Output-data-with-zero-observations/m-p/574812#M162481</link>
      <description>&lt;P&gt;Can you post the output from the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=final;
table class;
run;&lt;BR /&gt;&lt;BR /&gt;data&amp;nbsp;demo;&lt;BR /&gt;set&amp;nbsp;final;&lt;BR /&gt;where&amp;nbsp;class&amp;nbsp;in&amp;nbsp;('OPIOID',&amp;nbsp;'BENZO');&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I suspect you're not matching the conditions in the data step for some reason, likely case differences but this would tell you that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OPIOID and BENZO would have to be in the data set as exactly those values.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 22:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Output-data-with-zero-observations/m-p/574812#M162481</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-18T22:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: Error:  Output data with zero observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Output-data-with-zero-observations/m-p/574816#M162485</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;Can someone help me decipher what is wrong with this code?&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;One thing that is wrong is that it is badly formatted.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That makes it hard to read, to understand&amp;nbsp;the logic, and to find errors.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Code should be well presented. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This takes seconds to implement, makes you look professional, and saves you hours of debugging.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Consider&lt;SPAN&gt;&amp;nbsp;the below equivalent data step. Which one is easier to read?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data OVERLAPPED; 
  set WORK.FINAL; 
  by DE_ID ONDATE; 
  if first.ONDATE then call missing( COUNT, TYPA, TYPB);
  if CLASS='OPIOID' then TYPA+1;
  if CLASS='BENZO ' then TYPB+1;
  COUNT+1;
  if last.ONDATE and COUNT gt 1 then do;
    if TYPA and TYPB then do; OLAP='O&amp;amp;B'; output; end;
    if TYPA gt 1     then do; OLAP='O  '; output; end;
    if TYPB gt 1     then do; OLAP='B  '; output; end;
  end;
  drop CLASS TYPA TYPB;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now as to why you get no records, the reason is that your data does not match you code, as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;said.&lt;/P&gt;
&lt;P&gt;The values sought in the code seem to be never found in the data.&lt;/P&gt;
&lt;P&gt;Maybe they are not uppercase, or they have leading spaces. Look at your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 03:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Output-data-with-zero-observations/m-p/574816#M162485</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-07-19T03:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Error:  Output data with zero observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Output-data-with-zero-observations/m-p/574818#M162487</link>
      <description>&lt;P&gt;Thank you for your prompt response Reeza. Please see below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;25250395&lt;/TD&gt;&lt;TD&gt;46.43&lt;/TD&gt;&lt;TD&gt;25250395&lt;/TD&gt;&lt;TD&gt;46.43&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;29136586&lt;/TD&gt;&lt;TD&gt;53.57&lt;/TD&gt;&lt;TD&gt;54386981&lt;/TD&gt;&lt;TD&gt;100.00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data=final;&lt;BR /&gt;&amp;nbsp;table class;&lt;BR /&gt;&amp;nbsp;run;&lt;/P&gt;&lt;P&gt;NOTE: Writing HTML Body file: sashtml1.htm&lt;BR /&gt;NOTE: There were 54550121 observations read from the data set WORK.FINAL.&lt;BR /&gt;NOTE: PROCEDURE FREQ used (Total process time):&lt;BR /&gt;real time 1:02.01&lt;BR /&gt;cpu time 10.42 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;data demo;set final;where class in ('OPIOID', 'BENZO');run;&lt;/P&gt;&lt;P&gt;NOTE: There were 0 observations read from the data set WORK.FINAL.&lt;BR /&gt;WHERE class in ('BENZO', 'OPIOID');&lt;BR /&gt;NOTE: The data set WORK.DEMO has 0 observations and 23 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 13.57 seconds&lt;BR /&gt;cpu time 7.21 second&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 22:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Output-data-with-zero-observations/m-p/574818#M162487</guid>
      <dc:creator>Anita3</dc:creator>
      <dc:date>2019-07-18T22:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: Error:  Output data with zero observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Output-data-with-zero-observations/m-p/574822#M162489</link>
      <description>As character strings, these are all different:&lt;BR /&gt;&lt;BR /&gt;OPIOID&lt;BR /&gt;  OPIOID&lt;BR /&gt;Opioid&lt;BR /&gt;opioid&lt;BR /&gt;&lt;BR /&gt;Your program has to match the values that are in your data.  Freeze started you in the right direction by suggesting PROC FREQ.  However, try switching the WHERE statement to a more informative version:&lt;BR /&gt;&lt;BR /&gt;where left(upcase(class)) in ('BENZO', 'OPIOID');</description>
      <pubDate>Thu, 18 Jul 2019 23:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Output-data-with-zero-observations/m-p/574822#M162489</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-07-18T23:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Error:  Output data with zero observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Output-data-with-zero-observations/m-p/574824#M162491</link>
      <description>&lt;P&gt;Thank you so much!!! Your suggestions worked!!!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 23:34:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Output-data-with-zero-observations/m-p/574824#M162491</guid>
      <dc:creator>Anita3</dc:creator>
      <dc:date>2019-07-18T23:34:57Z</dc:date>
    </item>
  </channel>
</rss>

