<?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: Apparent symbolic reference FILENAME not resolved in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-FILENAME-not-resolved/m-p/659013#M197444</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;        data _NULL_;
            set a (firstobs=&amp;amp;i obs=&amp;amp;i); ;
            
            call symput('filename',strip(filename1));
            %put "&amp;amp;filename."; 
        run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The %put is resolved while the data step code is fetched for compiling, so this happens long before the data step actually runs. Move it after the RUN statement that ends the data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;        data _NULL_;
            set a (firstobs=&amp;amp;i obs=&amp;amp;i); ;
            
            call symput('filename',strip(filename1)); 
        run;
        %put "&amp;amp;filename.";&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 15 Jun 2020 14:38:13 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-06-15T14:38:13Z</dc:date>
    <item>
      <title>Apparent symbolic reference FILENAME not resolved</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-FILENAME-not-resolved/m-p/659011#M197442</link>
      <description>&lt;P&gt;All,&lt;/P&gt;&lt;P&gt;I am getting this below warning but all seems fine in the code.please advice me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference FILENAME not resolved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;

proc sql;
create table a(filename1 char(10));
insert into a values('test1.txt')
				values('test2.txt')
				values('test3.txt');
quit;
proc sql noprint;
         select count(*)
               into :fileCount
           from a;
           %put " file count is:%sysfunc(strip(&amp;amp;fileCount.))";
    quit;
     %do i=1 %to &amp;amp;fileCount.;
        data _NULL_;
            set a (firstobs=&amp;amp;i obs=&amp;amp;i); ;
            
            call symput('filename',strip(filename1));
            %put "&amp;amp;filename."; 
        run;
%end;
%mend test;
%test;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;SS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 14:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-FILENAME-not-resolved/m-p/659011#M197442</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2020-06-15T14:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference FILENAME not resolved</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-FILENAME-not-resolved/m-p/659013#M197444</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;        data _NULL_;
            set a (firstobs=&amp;amp;i obs=&amp;amp;i); ;
            
            call symput('filename',strip(filename1));
            %put "&amp;amp;filename."; 
        run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The %put is resolved while the data step code is fetched for compiling, so this happens long before the data step actually runs. Move it after the RUN statement that ends the data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;        data _NULL_;
            set a (firstobs=&amp;amp;i obs=&amp;amp;i); ;
            
            call symput('filename',strip(filename1)); 
        run;
        %put "&amp;amp;filename.";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Jun 2020 14:38:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-FILENAME-not-resolved/m-p/659013#M197444</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-15T14:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference FILENAME not resolved</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-FILENAME-not-resolved/m-p/659015#M197446</link>
      <description>&lt;P&gt;There is a timing issue when referencing macro variables in a data step. Basically they resolve in the compile phase prior to any data being read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your filename macro variable created this way will only have the value of the last value of filename1 any way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to create a bunch of macro variables from a data set you might consider&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table a(filename1 char(10));
insert into a values('test1.txt')
				values('test2.txt')
				values('test3.txt');
quit;
proc sql noprint;
   select  filename1 into : file1- :file10
   from a
   ;
quit;
%let filecount = &amp;amp;sqlobs;

%put _user_;&lt;/PRE&gt;
&lt;P&gt;As long as the number of the second :filexx is greater than or equal to the number of actual files in the data set it will only create one for each value. The automatic variable &amp;amp;sqlobs has the number of records returned from the last Proc SQL step, so saving it immediately after the Proc SQL step lets you have the iterator if needed.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 14:44:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-FILENAME-not-resolved/m-p/659015#M197446</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-15T14:44:22Z</dc:date>
    </item>
  </channel>
</rss>

