<?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: Can you control a PROC SQL statement not to print? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/738566#M28897</link>
    <description>&lt;P&gt;In Proc SQL there is noprint option, so use it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc sql noprint;&lt;/P&gt;
&lt;P&gt;select * from example&lt;/P&gt;
&lt;P&gt;where x= 'd';&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
    <pubDate>Mon, 03 May 2021 12:32:34 GMT</pubDate>
    <dc:creator>Aku</dc:creator>
    <dc:date>2021-05-03T12:32:34Z</dc:date>
    <item>
      <title>Can you control a PROC SQL statement not to print?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/738037#M28858</link>
      <description>&lt;P&gt;&lt;SPAN&gt;data example;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;input x $ y;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;datalines;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;a 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;c 5&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;proc&amp;nbsp;sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;select&amp;nbsp;*&amp;nbsp;from&amp;nbsp;example&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;where&amp;nbsp;x&amp;nbsp;=&amp;nbsp;'c';&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;proc&amp;nbsp;sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;select&amp;nbsp;* from&amp;nbsp;example&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;where&amp;nbsp;x&amp;nbsp;=&amp;nbsp;'d';&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;The first PROC SQL will print the result, but the second PROC SQL will print out an empty dataset. If I have dozens of these PROC SQL statements, is there a way to have the PROC SQL print out only if there is a matching record and PROC SQL like the second one not to print anything to the output window? I tried using a Having and Group By. It worked but prints out an extra CNT column.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;select x, count(*) as CNT&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from example&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;group by x&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;having CNT &amp;gt; 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;I have thought about creating a new dataset just to store the results and do another PROC SQL to get the result off that dataset. I don't think it's very efficient.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance for your help!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 21:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/738037#M28858</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2021-04-29T21:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Can you control a PROC SQL statement not to print?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/738041#M28860</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc SQL is inefficient for simple printing and Proc print doesn't create output when there is nothing to print because of a WHERE statement.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc print data=example ;&lt;BR /&gt;where x='d';&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 22:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/738041#M28860</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-04-29T22:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Can you control a PROC SQL statement not to print?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/738566#M28897</link>
      <description>&lt;P&gt;In Proc SQL there is noprint option, so use it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc sql noprint;&lt;/P&gt;
&lt;P&gt;select * from example&lt;/P&gt;
&lt;P&gt;where x= 'd';&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 12:32:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/738566#M28897</guid>
      <dc:creator>Aku</dc:creator>
      <dc:date>2021-05-03T12:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Can you control a PROC SQL statement not to print?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/738575#M28898</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; 70         proc sql;
 71           select * from example
 72           where x = 'd';
 NOTE: No rows were selected.
 73         quit;&lt;/PRE&gt;
&lt;P&gt;A note is added to the LOG,&lt;/P&gt;
&lt;P&gt;and nothing is printed in the results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 12:57:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/738575#M28898</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-05-03T12:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: Can you control a PROC SQL statement not to print?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/739000#M28923</link>
      <description>I know about the noprint. It is not ideal for my situation because the content of the datasets change so I only want it to print if it is not an empty data set.</description>
      <pubDate>Tue, 04 May 2021 18:01:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/739000#M28923</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2021-05-04T18:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Can you control a PROC SQL statement not to print?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/739002#M28924</link>
      <description>I haven't tested this but I think that's when you run one code on one dataset. I'm running a bunch of code on a bunch of dataset. So in the output window, I'll have the non-empty dataset along with empty data sets with just their dataset names. So I was looking for a solution to get rid off these empty datasets. Something like:&lt;BR /&gt;if nobs &amp;gt; 0;&lt;BR /&gt;proc print data=data_name;&lt;BR /&gt;run;&lt;BR /&gt;I guess there's no such thing.</description>
      <pubDate>Tue, 04 May 2021 18:04:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/739002#M28924</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2021-05-04T18:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: Can you control a PROC SQL statement not to print?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/739012#M28925</link>
      <description>Hi ballardw,&lt;BR /&gt;&lt;BR /&gt;Thanks for replying to all of my posts. I find a solution to the error message problem. If I use Quick Reply instead of Reply, then it will let me reply to posts. but unfortunately, there's not a Quick Post button.&lt;BR /&gt;&lt;BR /&gt;Is there a way to reference the number of observations in a dataset? like:&lt;BR /&gt;&lt;BR /&gt;proc print data=example;&lt;BR /&gt;where number_of_obs &amp;gt; 0;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;or something like&lt;BR /&gt;&lt;BR /&gt;if example.number_of_obs &amp;gt; 0 then&lt;BR /&gt;proc print data=example;&lt;BR /&gt;run;</description>
      <pubDate>Tue, 04 May 2021 18:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/739012#M28925</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2021-05-04T18:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Can you control a PROC SQL statement not to print?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/739037#M28926</link>
      <description>I resolved the problem, not very efficient but it got what I wanted. I wrote saved the number of obs of the dataset into a mac var and then used that mac inside a macro with a if statement.</description>
      <pubDate>Tue, 04 May 2021 18:57:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-you-control-a-PROC-SQL-statement-not-to-print/m-p/739037#M28926</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2021-05-04T18:57:39Z</dc:date>
    </item>
  </channel>
</rss>

