<?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: Using substr within a %let definition? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-substr-within-a-let-definition/m-p/9791#M775</link>
    <description>You need to use a macro function not a data step function&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%let filenm=%substr(&amp;amp;filename,1,5);&lt;BR /&gt;
&lt;BR /&gt;
This should get what you are looking for</description>
    <pubDate>Mon, 26 Apr 2010 14:17:10 GMT</pubDate>
    <dc:creator>darrylovia</dc:creator>
    <dc:date>2010-04-26T14:17:10Z</dc:date>
    <item>
      <title>Using substr within a %let definition?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-substr-within-a-let-definition/m-p/9790#M774</link>
      <description>I would like to create a macro variable based on a different macro variable is this possible?  I need to use a part of the filename macro variable to create another one to use as a way to name my data set.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
%let filename = ABCDE1234 ;&lt;BR /&gt;
%let path = c:\temp\ ;&lt;BR /&gt;
%let filenm = substr("&amp;amp;filename.",1,5) ;&lt;BR /&gt;
&lt;BR /&gt;
options symbolgen ;&lt;BR /&gt;
&lt;BR /&gt;
filename indata "&amp;amp;path&amp;amp;filename..txt";&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data &amp;amp;filenm   ;&lt;BR /&gt;
  infile indata dsd truncover;                            &lt;BR /&gt;
  input num ?? @ ;     &lt;BR /&gt;
  do while( num ne . );&lt;BR /&gt;
     output ;&lt;BR /&gt;
     input num ?? @ ;&lt;BR /&gt;
  end ;&lt;BR /&gt;
run ;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
This is the text from the log &lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
SYMBOLGEN:  Macro variable FILENM resolves to substr("ABCDE1234",1,5)&lt;BR /&gt;
544  data &amp;amp;filenm   ;&lt;BR /&gt;
NOTE: Line generated by the macro variable "FILENM".&lt;BR /&gt;
1     substr("ABCDE1234",1,5)&lt;BR /&gt;
             -----------&lt;BR /&gt;
             22&lt;BR /&gt;
ERROR 22-7: Invalid option name "ABCDE1234".&lt;BR /&gt;
&lt;BR /&gt;
545    infile indata dsd truncover;&lt;BR /&gt;
546    input num ?? @ ;&lt;BR /&gt;
547    do while( num ne . );&lt;BR /&gt;
548       output ;&lt;BR /&gt;
549       input num ?? @ ;&lt;BR /&gt;
550    end ;&lt;BR /&gt;
551  run ;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
NOTE: DATA statement 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;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Thank you for any help</description>
      <pubDate>Mon, 26 Apr 2010 13:56:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-substr-within-a-let-definition/m-p/9790#M774</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2010-04-26T13:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using substr within a %let definition?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-substr-within-a-let-definition/m-p/9791#M775</link>
      <description>You need to use a macro function not a data step function&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%let filenm=%substr(&amp;amp;filename,1,5);&lt;BR /&gt;
&lt;BR /&gt;
This should get what you are looking for</description>
      <pubDate>Mon, 26 Apr 2010 14:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-substr-within-a-let-definition/m-p/9791#M775</guid>
      <dc:creator>darrylovia</dc:creator>
      <dc:date>2010-04-26T14:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using substr within a %let definition?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-substr-within-a-let-definition/m-p/9792#M776</link>
      <description>darry,&lt;BR /&gt;
&lt;BR /&gt;
That was it thanks so much for the quick reply.</description>
      <pubDate>Mon, 26 Apr 2010 15:02:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-substr-within-a-let-definition/m-p/9792#M776</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2010-04-26T15:02:40Z</dc:date>
    </item>
  </channel>
</rss>

