<?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: Insert macro variable into dataset name? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Insert-macro-variable-into-dataset-name/m-p/975113#M378045</link>
    <description>Yes, as simple as a simple period.  Thanks for your help.&lt;BR /&gt;Gene</description>
    <pubDate>Mon, 15 Sep 2025 17:40:58 GMT</pubDate>
    <dc:creator>genemroz</dc:creator>
    <dc:date>2025-09-15T17:40:58Z</dc:date>
    <item>
      <title>Insert macro variable into dataset name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-macro-variable-into-dataset-name/m-p/975110#M378043</link>
      <description>&lt;P&gt;I'm trying to use a macro variable as part of a dataset name and not having any success. &amp;nbsp;Here's a simplifed version of what I'm trying to do that generates a Syntax Error message . &amp;nbsp;I want to get a dataset name of 'US000D_output'. I'm missing something simple but it is eluding me.&lt;/P&gt;
&lt;P&gt;Thanks in advance for any help you can provide,&lt;/P&gt;
&lt;P&gt;Gene&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data input;
Length text $30 station $6;
Text='/Prefix/US000D/Suffix/';
Station=scan(text,2);
Call symput('StationID',Station);
put &amp;amp;StationID;
run;

data &amp;amp;StationID_output;
set input;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Sep 2025 17:14:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-macro-variable-into-dataset-name/m-p/975110#M378043</guid>
      <dc:creator>genemroz</dc:creator>
      <dc:date>2025-09-15T17:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: Insert macro variable into dataset name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-macro-variable-into-dataset-name/m-p/975111#M378044</link>
      <description>&lt;P&gt;You need a period to tell SAS where the macro variable name stops. Also a macro variable created with CALL SYMPUT will not resolve until a step boundary is reached.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data input;
Length text $30 station $6;
Text='/Prefix/US000D/Suffix/';
Station=scan(text,2);
Call symput('StationID',Station);
run;
%put &amp;amp;StationID;

data &amp;amp;StationID._output;
set input;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Sep 2025 17:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-macro-variable-into-dataset-name/m-p/975111#M378044</guid>
      <dc:creator>Kathryn_SAS</dc:creator>
      <dc:date>2025-09-15T17:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: Insert macro variable into dataset name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-macro-variable-into-dataset-name/m-p/975113#M378045</link>
      <description>Yes, as simple as a simple period.  Thanks for your help.&lt;BR /&gt;Gene</description>
      <pubDate>Mon, 15 Sep 2025 17:40:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-macro-variable-into-dataset-name/m-p/975113#M378045</guid>
      <dc:creator>genemroz</dc:creator>
      <dc:date>2025-09-15T17:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Insert macro variable into dataset name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-macro-variable-into-dataset-name/m-p/975118#M378048</link>
      <description>&lt;P&gt;You might also want to consider making sure that the resolved name doesn't exceed the SAS naming limits. Nothing like trying to use "too_long_of_a_macrovariable_output" only to later find the actual name of the data set is "too_long_of_a_macrovariable_out" because of the 32 character limit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similar considerations are in effect for Library, Catalog and File reference names.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Sep 2025 19:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-macro-variable-into-dataset-name/m-p/975118#M378048</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-09-15T19:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: Insert macro variable into dataset name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Insert-macro-variable-into-dataset-name/m-p/975126#M378049</link>
      <description>&lt;P&gt;You should only use the ancient CALL SYMPUT() routine when it is important that leading and/or trailing spaces be put into the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead use its replacement the CALL SYMPUTX() routine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it worked for you it is only because the result of the SCAN() function call completely filled the variable STATION which you defined as length $6.&amp;nbsp; If STATION had been defined longer or the value pulled out of TEXT had been shorter you would have put one or more trailing spaces into the macro variable STATIONID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In which case your data step would have made two output datasets since you would have told SAS to run something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data U0000D     _output ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Sep 2025 20:57:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Insert-macro-variable-into-dataset-name/m-p/975126#M378049</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-15T20:57:52Z</dc:date>
    </item>
  </channel>
</rss>

