<?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: Macros in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Macros/m-p/563518#M10895</link>
    <description>&lt;P&gt;Can I ask why ? Thank you.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Jun 2019 13:43:09 GMT</pubDate>
    <dc:creator>kedii_9</dc:creator>
    <dc:date>2019-06-04T13:43:09Z</dc:date>
    <item>
      <title>Macros</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macros/m-p/563499#M10889</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am trying to use Macro to print dataset sashelp.cars and sashelp.cars.&amp;nbsp; But every time I try to run the code below it got errors.&lt;BR /&gt;How can I correct? Thank you.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro printz/parmbuff;&lt;BR /&gt;%let num=1;&lt;BR /&gt;%let dsname=%scan(&amp;amp;syspbuff,&amp;amp;num,',');&lt;BR /&gt;%do %while(&amp;amp;dsname ne);&lt;BR /&gt;proc print data=sashelp.&amp;amp;dsname;&lt;BR /&gt;run;&lt;BR /&gt;%let num=%eval(&amp;amp;num+1);&lt;BR /&gt;%let dsname=%scan(&amp;amp;syspbuff,&amp;amp;num);&lt;BR /&gt;%end;&lt;BR /&gt;%mend printz;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%printz(air,cars);&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2019 12:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macros/m-p/563499#M10889</guid>
      <dc:creator>kedii_9</dc:creator>
      <dc:date>2019-06-04T12:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macros</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macros/m-p/563507#M10891</link>
      <description>&lt;P&gt;Just get rid of the third argument in your %SCAN details ( the ',').&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO PRINTZ /PARMBUFF;
	%LET num=1;
	%LET DSNAME=%SCAN(&amp;amp;SYSPBUFF,&amp;amp;NUM);
	%DO %WHILE(&amp;amp;DSNAME NE);
		PROC PRINT DATA=SASHELP.&amp;amp;DSNAME;
		RUN;
		%LET NUM=%EVAL(&amp;amp;NUM+1);
		%LET DSNAME=%SCAN(&amp;amp;SYSPBUFF,&amp;amp;NUM);
	%END;
%MEND PRINTZ;

%PRINTZ(Air,Cars);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Jun 2019 12:54:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macros/m-p/563507#M10891</guid>
      <dc:creator>tsap</dc:creator>
      <dc:date>2019-06-04T12:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Macros</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macros/m-p/563518#M10895</link>
      <description>&lt;P&gt;Can I ask why ? Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2019 13:43:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macros/m-p/563518#M10895</guid>
      <dc:creator>kedii_9</dc:creator>
      <dc:date>2019-06-04T13:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macros</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macros/m-p/563548#M10898</link>
      <description>&lt;P&gt;The parentheses are included in the value of the SYSPBUFF macro variable.&lt;/P&gt;
&lt;P&gt;You can just remove them first and then start scanning the value.&amp;nbsp; Or if you know that users will never provide dataset options you could replace the single quotes in your list of delimiters with parentheses instead.&amp;nbsp; (Not sure why you wanted to include single quotes as one of the delimiters anyway.)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dsname=%scan(&amp;amp;syspbuff,&amp;amp;num,(,));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would use a simple iterative %DO loop instead of adding all that extra code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro printz/parmbuff;
%local num dsname;
%let num=%length(&amp;amp;syspbuff);
%if &amp;amp;num&amp;gt;2 %then %let syspbuff=%qsubstr(&amp;amp;syspbuff,2,&amp;amp;num-2);
%do num=1 %to %sysfunc(countw(&amp;amp;syspbuff,%str(,)));
  %let dsname=%scan(&amp;amp;syspbuff,&amp;amp;num,%str(,));
proc print data=sashelp.&amp;amp;dsname;
run;
%end;
%mend printz;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Jun 2019 15:17:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macros/m-p/563548#M10898</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-04T15:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macros</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macros/m-p/563818#M10939</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Using Default Delimiters in ASCII and EBCDIC Environments

If you use the SCAN function with only two arguments, then the default delimiters depend on whether your computer uses ASCII or EBCDIC characters. 
•If your computer uses ASCII characters, then the default delimiters are as follows: 
blank ! $ % &amp;amp; ( ) * + , - . / ; &amp;lt; ^ [Using Default Delimiters in ASCII and EBCDIC Environments]
In ASCII environments that do not contain the ^ character, the SCAN function uses the ~ character instead.

•If your computer uses EBCDIC characters, then the default delimiters are as follows: 
blank ! $ % &amp;amp; ( ) * + , - . / ; &amp;lt; ¬ | ¢ [Using Default Delimiters in ASCII and EBCDIC Environments]

If you use the modifier argument without specifying any characters as delimiters, then the only delimiters that will be used are delimiters that are defined by the modifier argument. In this case, the lists of default delimiters for ASCII and EBCDIC environments are not used. In other words, modifiers add to the list of delimiters that are explicitly specified by the charlist argument. Modifiers do not add to the list of default modifiers.&lt;/PRE&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm" target="_self"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By putting ',' as your third argument in your scan function details, you are telling it to only use those delimiter values and not the default values. So you get an error when you run your process. However, when you remove the third argument, the scan function uses the default list of delimiters as shown above. Included in this list is the open and close parentheses. So it doesn't see the parentheses as actual characters, but instead as only delimiters so when it looks for the first table name it pulls in the appropriate details.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2019 18:35:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macros/m-p/563818#M10939</guid>
      <dc:creator>tsap</dc:creator>
      <dc:date>2019-06-05T18:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: Macros</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macros/m-p/564651#M11090</link>
      <description>Thank you for your response. It's really helpful !!&lt;BR /&gt;</description>
      <pubDate>Sat, 08 Jun 2019 13:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macros/m-p/564651#M11090</guid>
      <dc:creator>kedii_9</dc:creator>
      <dc:date>2019-06-08T13:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: Macros</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macros/m-p/564659#M11092</link>
      <description>&lt;P&gt;Unless you actual macro is much more complicated than your example you do NOT need to use PARMBUFF option for this macro.&amp;nbsp; Just use something other than a comma in your list of dataset names.&amp;nbsp; The natural thing to use as a delimiter in SAS code is a space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro printz(dslist);
%local i ds ;
%do i=1 %to %sysfunc(countw(&amp;amp;dslist,%str( )));
  %let ds=%scan(&amp;amp;dslist,&amp;amp;i,%str( ));
....
%end;
%mend printz;
%printz(class cars);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Jun 2019 14:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macros/m-p/564659#M11092</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-08T14:35:40Z</dc:date>
    </item>
  </channel>
</rss>

