<?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 If results in dataset then write message to results window in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-results-in-dataset-then-write-message-to-results-window/m-p/860545#M339949</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have a fairly simple program that I need to create that will display text depending on two conditions of a dataset. The program runs but the text is not displayed in the results window but rather in the log. How can I write the below to get the text to show once the program is run without having to look in the log?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _NULL_;
set me.prim_data nobs=numobs;
if numobs&amp;gt;0 and payment_channel = 'CREDIT' then PUT 'NEED CREDIT FILE AND LETTER';
RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Feb 2023 19:42:03 GMT</pubDate>
    <dc:creator>JC411911</dc:creator>
    <dc:date>2023-02-23T19:42:03Z</dc:date>
    <item>
      <title>If results in dataset then write message to results window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-results-in-dataset-then-write-message-to-results-window/m-p/860545#M339949</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have a fairly simple program that I need to create that will display text depending on two conditions of a dataset. The program runs but the text is not displayed in the results window but rather in the log. How can I write the below to get the text to show once the program is run without having to look in the log?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _NULL_;
set me.prim_data nobs=numobs;
if numobs&amp;gt;0 and payment_channel = 'CREDIT' then PUT 'NEED CREDIT FILE AND LETTER';
RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 19:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-results-in-dataset-then-write-message-to-results-window/m-p/860545#M339949</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2023-02-23T19:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: If results in dataset then write message to results window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-results-in-dataset-then-write-message-to-results-window/m-p/860546#M339950</link>
      <description>&lt;P&gt;Just add a FILE statement to tell the data step where you want it to go.&lt;/P&gt;
&lt;P&gt;For example use FILE PRINT to write to whatever ODS destinations you have open.&lt;/P&gt;
&lt;P&gt;Note you cannot test for NUMOBS=0 after the SET statement because if it is zero then the SET statement is the last statement that will execute because it will read past the end of the input.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
  file print;
  if numobs=0 then put 'FILE IS EMPTY';
  set me.prim_data nobs=numobs;
  if  payment_channel = 'CREDIT' then PUT 'NEED CREDIT FILE AND LETTER';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Do you really want to write that message for every observation that has payment_channel equal to CREDIT?&lt;/P&gt;
&lt;P&gt;How many observations are in that dataset?&amp;nbsp; You might want to stop at the first one.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
  file print;
  if numobs=0 then put 'FILE IS EMPTY';
  set me.prim_data nobs=numobs;
  if  payment_channel = 'CREDIT' then do;
    PUT 'NEED CREDIT FILE AND LETTER';
    stop;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Feb 2023 19:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-results-in-dataset-then-write-message-to-results-window/m-p/860546#M339950</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-23T19:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: If results in dataset then write message to results window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-results-in-dataset-then-write-message-to-results-window/m-p/860549#M339952</link>
      <description>Ah that worked. This may be nitpicky but is there a way to just get the text to list one time regardless if the statement is true and there are many observations? In that result I see "NEED CREDIT FILE AND LETTER" multiple times since there are hundreds of obrservations that meet the criteria.</description>
      <pubDate>Thu, 23 Feb 2023 19:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-results-in-dataset-then-write-message-to-results-window/m-p/860549#M339952</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2023-02-23T19:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: If results in dataset then write message to results window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-results-in-dataset-then-write-message-to-results-window/m-p/860553#M339954</link>
      <description>&lt;LI-CODE lang="sas"&gt;data _NULL_;
  file print;
  if numobs=0 then put 'FILE IS EMPTY';
  set me.prim_data nobs=numobs;
  retain flag 0;
  if  payment_channel = 'CREDIT' and flag=0 then do;
    PUT 'NEED CREDIT FILE AND LETTER';
    flag=1;
    stop;
  end;
run;&lt;/LI-CODE&gt;
&lt;P&gt;The retain keeps a variable's value across iteration of the data step. So initialize to 0, in example, and then the first time you execute the Put change the value to something else.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 20:02:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-results-in-dataset-then-write-message-to-results-window/m-p/860553#M339954</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-23T20:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: If results in dataset then write message to results window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-results-in-dataset-then-write-message-to-results-window/m-p/860556#M339956</link>
      <description>&lt;P&gt;Just STOP.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even easier if you use a WHERE statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_:
  file print;
  if 0=numobs then put 'None found';
  set mydata nobs=numobs;
  where (xx='CHECK');
  put 'Found some.';
  stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 20:09:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-results-in-dataset-then-write-message-to-results-window/m-p/860556#M339956</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-23T20:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: If results in dataset then write message to results window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-results-in-dataset-then-write-message-to-results-window/m-p/860557#M339957</link>
      <description>&lt;P&gt;Use CALL EXECUTE + PROC ODSTEXT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
set sashelp.class nobs=numobs;
if numobs&amp;gt;0  then call execute("proc odstext;
   p 'NEED CREDIT FILE AND LETTER'  / style=[color=red fontsize=25pt];
run;");
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/371433"&gt;@JC411911&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have a fairly simple program that I need to create that will display text depending on two conditions of a dataset. The program runs but the text is not displayed in the results window but rather in the log. How can I write the below to get the text to show once the program is run without having to look in the log?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _NULL_;
set me.prim_data nobs=numobs;
if numobs&amp;gt;0 and payment_channel = 'CREDIT' then PUT 'NEED CREDIT FILE AND LETTER';
RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 20:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-results-in-dataset-then-write-message-to-results-window/m-p/860557#M339957</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-02-23T20:12:06Z</dc:date>
    </item>
  </channel>
</rss>

