<?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: What my Macro is Missing? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-my-Macro-is-Missing/m-p/418575#M102849</link>
    <description>&lt;P&gt;If empty dataset, a message will be assigned to a specific variable (either subject or rand_id) depending on which dataset name.&lt;/P&gt;</description>
    <pubDate>Tue, 05 Dec 2017 18:58:56 GMT</pubDate>
    <dc:creator>mehong19</dc:creator>
    <dc:date>2017-12-05T18:58:56Z</dc:date>
    <item>
      <title>What my Macro is Missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-my-Macro-is-Missing/m-p/418565#M102843</link>
      <description>&lt;P&gt;I wanted to put a message to a specific variable in a specific dataset if that dataset is empty. I wrote the program below and got error messages in log. Could someone help me with it? Many thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*program*/&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; num_obs=; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; check_empty_dataset(ds=);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;select count(*) into :num_obs from &amp;amp;ds;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;=num_obs;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;ds in (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Chk_pk_ppd_edc_data_pknd_2"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;num_obs = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data tmp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;length rand_id $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;100&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;rand_id = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'*** NO RESULTS FOR THIS PK SAMPLE CHECK ***'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data &amp;amp;ds;&lt;/P&gt;&lt;P&gt;set tmp &amp;amp;ds ;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;*keep note;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Log*/&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK_EMPTY_DATASET): Beginning execution.&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK_EMPTY_DATASET): Parameter DS has value Chk_pk_ppd_edc_data_pknd_2&lt;/P&gt;&lt;P&gt;MPRINT(CHECK_EMPTY_DATASET): proc sql noprint;&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable DS resolves to Chk_pk_ppd_edc_data_pknd_2&lt;/P&gt;&lt;P&gt;MPRINT(CHECK_EMPTY_DATASET): select count(*) into :num_obs from Chk_pk_ppd_edc_data_pknd_2;&lt;/P&gt;&lt;P&gt;MPRINT(CHECK_EMPTY_DATASET): quit;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.00 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK_EMPTY_DATASET): %PUT &amp;amp;=num_obs&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable NUM_OBS resolves to 0&lt;/P&gt;&lt;P&gt;NUM_OBS= 0&lt;/P&gt;&lt;P&gt;SYMBOLGEN: Macro variable DS resolves to Chk_pk_ppd_edc_data_pknd_2&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;ERROR: Required operator not found in expression: &amp;amp;ds in ("Chk_pk_ppd_edc_data_pknd_2")&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;ERROR: The macro CHECK_EMPTY_DATASET will stop executing.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;MLOGIC(CHECK_EMPTY_DATASET): Ending execution.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 18:35:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-my-Macro-is-Missing/m-p/418565#M102843</guid>
      <dc:creator>mehong19</dc:creator>
      <dc:date>2017-12-05T18:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: What my Macro is Missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-my-Macro-is-Missing/m-p/418567#M102845</link>
      <description>&lt;P&gt;What happens in this step if the table is empty or doesn't exist?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select count(*) into :num_obs from &amp;amp;ds;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Dec 2017 18:37:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-my-Macro-is-Missing/m-p/418567#M102845</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-05T18:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: What my Macro is Missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-my-Macro-is-Missing/m-p/418570#M102848</link>
      <description>&lt;P&gt;The syntax for IN is different in macro language vs. the DATA step.&amp;nbsp; You would also need to properly set two options, MINOPERATOR and MINDELIMITER.&amp;nbsp; Why not get rid of IN, and just use an equal comparison?&amp;nbsp; Do you really need to compare to a list of data set names?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 18:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-my-Macro-is-Missing/m-p/418570#M102848</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-12-05T18:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: What my Macro is Missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-my-Macro-is-Missing/m-p/418575#M102849</link>
      <description>&lt;P&gt;If empty dataset, a message will be assigned to a specific variable (either subject or rand_id) depending on which dataset name.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 18:58:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-my-Macro-is-Missing/m-p/418575#M102849</guid>
      <dc:creator>mehong19</dc:creator>
      <dc:date>2017-12-05T18:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: What my Macro is Missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-my-Macro-is-Missing/m-p/418576#M102850</link>
      <description>I have a list of datasets (about 10 datasets) to check if they are empty or not. Depending on the dataset name, the empty-dataset text will be assigned to a different variable (ie. subject or rand_id).</description>
      <pubDate>Tue, 05 Dec 2017 19:03:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-my-Macro-is-Missing/m-p/418576#M102850</guid>
      <dc:creator>mehong19</dc:creator>
      <dc:date>2017-12-05T19:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: What my Macro is Missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-my-Macro-is-Missing/m-p/418578#M102851</link>
      <description>I tried. But the output is not as expected. The program and log are as below.&lt;BR /&gt;&lt;BR /&gt;1071 %let num_obs=;&lt;BR /&gt;1072 %macro check_empty_dataset(ds=);&lt;BR /&gt;1073 proc sql noprint;&lt;BR /&gt;1074 select count(*) into :num_obs from &amp;amp;ds;&lt;BR /&gt;1075 quit;&lt;BR /&gt;1076 %put &amp;amp;=num_obs;&lt;BR /&gt;1077&lt;BR /&gt;1078 %if &amp;amp;ds = "Chk_pk_ppd_edc_data_pknd_2" %then %do;&lt;BR /&gt;1079 %if &amp;amp;num_obs = 0 %then %do;&lt;BR /&gt;1080 data tmp;&lt;BR /&gt;1081 length rand_id $100;&lt;BR /&gt;1082 rand_id = '*** NO RESULTS FOR THIS PK SAMPLE CHECK ***';&lt;BR /&gt;1083 run;&lt;BR /&gt;1084&lt;BR /&gt;1085 data &amp;amp;ds;&lt;BR /&gt;1086 set tmp &amp;amp;ds ;&lt;BR /&gt;1087 *keep note;&lt;BR /&gt;1088 run;&lt;BR /&gt;1089 %end;&lt;BR /&gt;1090 %end;&lt;BR /&gt;1091 %mend;&lt;BR /&gt;MPRINT():&lt;BR /&gt;&lt;BR /&gt;1092 %check_empty_dataset(ds=Chk_pk_ppd_edc_data_pknd_2);&lt;BR /&gt;MLOGIC(CHECK_EMPTY_DATASET): Beginning execution.&lt;BR /&gt;MLOGIC(CHECK_EMPTY_DATASET): Parameter DS has value Chk_pk_ppd_edc_data_pknd_2&lt;BR /&gt;MPRINT(CHECK_EMPTY_DATASET): proc sql noprint;&lt;BR /&gt;SYMBOLGEN: Macro variable DS resolves to Chk_pk_ppd_edc_data_pknd_2&lt;BR /&gt;MPRINT(CHECK_EMPTY_DATASET): select count(*) into :num_obs from Chk_pk_ppd_edc_data_pknd_2;&lt;BR /&gt;MPRINT(CHECK_EMPTY_DATASET): quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;MLOGIC(CHECK_EMPTY_DATASET): %PUT &amp;amp;=num_obs&lt;BR /&gt;SYMBOLGEN: Macro variable NUM_OBS resolves to 0&lt;BR /&gt;NUM_OBS= 0&lt;BR /&gt;SYMBOLGEN: Macro variable DS resolves to Chk_pk_ppd_edc_data_pknd_2&lt;BR /&gt;MLOGIC(CHECK_EMPTY_DATASET): %IF condition &amp;amp;ds = "Chk_pk_ppd_edc_data_pknd_2" is FALSE&lt;BR /&gt;MLOGIC(CHECK_EMPTY_DATASET): Ending execution.&lt;BR /&gt;</description>
      <pubDate>Tue, 05 Dec 2017 19:06:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-my-Macro-is-Missing/m-p/418578#M102851</guid>
      <dc:creator>mehong19</dc:creator>
      <dc:date>2017-12-05T19:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: What my Macro is Missing?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-my-Macro-is-Missing/m-p/418580#M102852</link>
      <description>&lt;P&gt;Macro language wouldn't need quotes around a string.&amp;nbsp; Removing the quotes should work for just a single data set name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a brief example that shows how to use the proper options to compare to a list of values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/35/591.html" target="_blank"&gt;http://support.sas.com/kb/35/591.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm sure you can find additional examples if you need them.&amp;nbsp; Do not add quotes, and do not insert spaces on either side of your delimiter.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2017 19:09:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-my-Macro-is-Missing/m-p/418580#M102852</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-12-05T19:09:28Z</dc:date>
    </item>
  </channel>
</rss>

