<?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: resolve program issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925579#M364232</link>
    <description>set test%if &amp;amp;out=1 %then %do;test2%end; actuall if code like above,after resoled,the log will show testtest2 dataset doesn't exit，but I find out that I need to add a space between %do; and test2,after resolved,the code will keep the space</description>
    <pubDate>Wed, 24 Apr 2024 14:35:27 GMT</pubDate>
    <dc:creator>wzl9527</dc:creator>
    <dc:date>2024-04-24T14:35:27Z</dc:date>
    <item>
      <title>resolve program issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925514#M364217</link>
      <description>&lt;P&gt;found issue about resolving macro, here is the macro:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data test;
 set sashelp.class;
run;

data test2;
 set sashelp.cars;
run;

%macro resolvema(name=,out=);
	data cc_&amp;amp;out;
		set test(where=(name="&amp;amp;name"))   
		%if &amp;amp;out=1 %then %do;test2%end;;
	run;

%mend;

%resolvema(name=Alfred,out=1);
%resolvema(name=Thomas,out=2);

data final;
	set cc_:;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;after I resolved the macro , the space between 'test(where=(name="Alfred"))test2;' was removed,which cause an error,Does anyone know how to fix this,below is the resolve macro&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let path_1=D:\Practice;
%let path_2=D:\Practice2;

%macro resopa(name=);
/*  options nomprint nomfile;*/

  filename mprint "&amp;amp;path_2\&amp;amp;name..sas";     
  options mprint mfile;                    
  run;
  %include "&amp;amp;path_1\&amp;amp;name..sas";   

      
  
%mend resopa;

%resopa(name=remacro);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;or Does anyone else know of other ways to resolve program(inclue macro),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 09:06:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925514#M364217</guid>
      <dc:creator>wzl9527</dc:creator>
      <dc:date>2024-04-24T09:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: resolve program issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925520#M364218</link>
      <description>&lt;P&gt;I don't get any errors in the log when I run your first block of code. What errors do you see? (Hint: in the future, don't say you are getting an error — show us the error in the log that you are getting)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the lack of a space bothers you, put a space in the macro code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;out=1 %then %do; test2%end;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your second block of code is unrelated to the first, and so I am not even sure what the question is about the 2nd block of code.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 10:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925520#M364218</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-04-24T10:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: resolve program issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925572#M364228</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/397137"&gt;@wzl9527&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;after I resolved the macro , the space between 'test(where=(name="Alfred"))test2;' was removed,which cause an error,Does anyone know how to fix this,below is the resolve macro&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What space? Between what?&amp;nbsp; The quoted string you show,&amp;nbsp;'test(where=(name="Alfred"))test2;' , does not contain any space to remove.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also ran your code for the first macro with no error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A comment on coding style inside macros. It may help to separate the code out a bit more so you can see the part adding the second, or subsequent, data set name(s) and where the Set statement is closed.&lt;/P&gt;
&lt;PRE&gt;%macro resolvema(name=,out=);
	data cc_&amp;amp;out;
	   set test(where=(name="&amp;amp;name"))   
   	      %if &amp;amp;out=1 %then %do;
                test2
             %end;
          ;  /* close set statement*/
	run;

%mend;&lt;/PRE&gt;
&lt;P&gt;It is very easy to lose track of why some, simple here but that %if could well become a complex loop, semicolon is doubled and accidentally clean it up or confuse where an expansion of this %if to a loop needs to end.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 15:42:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925572#M364228</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-24T15:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: resolve program issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925576#M364229</link>
      <description>&lt;P&gt;Your macros run fine for me, no errors.&lt;BR /&gt;&lt;BR /&gt;Also, when debugging a macro, it's often helpful to test the SAS code with no macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I submit:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cc_1;
  set test(where=(name="Alfred"))test2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It runs fine, no complaint about lack of space after the closing parenthesis.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 14:31:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925576#M364229</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-04-24T14:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: resolve program issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925577#M364230</link>
      <description>&lt;P&gt;set test%if &amp;amp;out=1 %then %do;test2%end;&lt;/P&gt;&lt;P&gt;actuall if code like above,after resoled,the log will show testtest2 dataset doesn't exit，but I find out that I need to add a space between %do; and test2,after resolved,the code will keep the space&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 14:32:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925577#M364230</guid>
      <dc:creator>wzl9527</dc:creator>
      <dc:date>2024-04-24T14:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: resolve program issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925578#M364231</link>
      <description>thanks ,i find out the answer</description>
      <pubDate>Wed, 24 Apr 2024 14:34:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925578#M364231</guid>
      <dc:creator>wzl9527</dc:creator>
      <dc:date>2024-04-24T14:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: resolve program issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925579#M364232</link>
      <description>set test%if &amp;amp;out=1 %then %do;test2%end; actuall if code like above,after resoled,the log will show testtest2 dataset doesn't exit，but I find out that I need to add a space between %do; and test2,after resolved,the code will keep the space</description>
      <pubDate>Wed, 24 Apr 2024 14:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925579#M364232</guid>
      <dc:creator>wzl9527</dc:creator>
      <dc:date>2024-04-24T14:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: resolve program issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925580#M364233</link>
      <description>&lt;P&gt;Please show us the log. Talking about the log is rather pointless.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 14:37:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925580#M364233</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-04-24T14:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: resolve program issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925582#M364235</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/397137"&gt;@wzl9527&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;thanks ,i find out the answer&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please share what you discovered so if someone comes to the forum with what they think is a similar issue they can see what the resolution could be.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 14:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925582#M364235</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-24T14:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: resolve program issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925583#M364236</link>
      <description>&lt;P&gt;Can you post an example and log that show the error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my head, I think this code, without the parentheses, &lt;STRONG&gt;should&lt;/STRONG&gt; generate an error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
options mprint;

data test;
 set sashelp.class;
run;

data test2;
 set sashelp.cars;
run;

%macro resolvema(name=,out=);
	data cc_&amp;amp;out;
		set test%if &amp;amp;out=1 %then %do;test2%end;;
 run;
%mend;

%resolvema(name=Alfred,out=1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Interestingly, MPRINT shows that the generated code has no space between test and test2, so the code does resolve to set test1test2; which should error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But due to some oddities in the tokenizer / word scanner, this actually builds separate tokens for test and test2.&amp;nbsp; The log is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;MPRINT(RESOLVEMA):   data cc_1;
MPRINT(RESOLVEMA):   set testtest2;
MPRINT(RESOLVEMA):   run;

NOTE: There were 19 observations read from the data set WORK.TEST.
NOTE: There were 428 observations read from the data set WORK.TEST2.
NOTE: The data set WORK.CC_1 has 447 observations and 19 variables.
&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Apr 2024 14:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolve-program-issue/m-p/925583#M364236</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-04-24T14:47:44Z</dc:date>
    </item>
  </channel>
</rss>

