<?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 How to define a dynamical path for FILE command in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-dynamical-path-for-FILE-command/m-p/299472#M63174</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been reading some posts and similar problems but I don't find the solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The structure of my program.sas is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%MACRO&lt;/STRONG&gt; &lt;STRONG&gt;&lt;EM&gt;CREA_XML&lt;/EM&gt;&lt;/STRONG&gt; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; file&amp;nbsp;&lt;STRONG&gt;" '/directory /folder/office1.xml "; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;------- it works but not change&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;&amp;nbsp;*file &amp;amp;path1.; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;----- DOESN'T WORK with macro &amp;amp;path1.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; %put &amp;amp;path1.; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt; &amp;nbsp;&amp;lt;------ &amp;amp;path1.=" '/directory /folder/office1.xml "&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT '&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT ' ';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT '&amp;lt;!DOCTYPE UPDATE SYSTEM "doc.dtd"&amp;gt;';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT ' ';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT '&amp;lt;DOC&amp;gt;';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT '&amp;nbsp;&amp;nbsp; &amp;lt;JOB&amp;gt;';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; line = '&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;APP FROM="'|| trim(&amp;amp;off) || '/&amp;gt;';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT line;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT '&amp;nbsp;&amp;nbsp; &amp;lt;/JOB&amp;gt;';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT '&amp;lt;/DOC&amp;gt;';&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%MEND &lt;EM&gt;CREA_XML&amp;nbsp;&lt;/EM&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SET dataset;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%LET off = office;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; path =&amp;nbsp;cat('"',"'",'&lt;SPAN&gt;/directory /folder/&lt;/SPAN&gt;',strip(&amp;amp;off.),'.xml"');&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %LET path1 = path;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;STRONG&gt; &amp;nbsp; &amp;nbsp; &lt;EM&gt;&amp;nbsp;%CREA_XML;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a &lt;U&gt;new .xml document&lt;/U&gt;, in the path&amp;nbsp;&lt;STRONG&gt; '/directory /folder/&lt;/STRONG&gt;, &lt;U&gt;for each office,&lt;/U&gt; so I build the path by concatenating the office in a loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I check how is the path in %CREA_XML, it is correct, but &lt;STRONG&gt;with FILE &amp;amp;path1. it doesn't write anything&lt;/STRONG&gt;. However, If i write all path (the same value that is inside the %path1.) it works. So..I am not able to dynamize it!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help me? I don't know why it is happening.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&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>Tue, 20 Sep 2016 10:10:00 GMT</pubDate>
    <dc:creator>MissConde</dc:creator>
    <dc:date>2016-09-20T10:10:00Z</dc:date>
    <item>
      <title>How to define a dynamical path for FILE command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-dynamical-path-for-FILE-command/m-p/299472#M63174</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been reading some posts and similar problems but I don't find the solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The structure of my program.sas is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%MACRO&lt;/STRONG&gt; &lt;STRONG&gt;&lt;EM&gt;CREA_XML&lt;/EM&gt;&lt;/STRONG&gt; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; file&amp;nbsp;&lt;STRONG&gt;" '/directory /folder/office1.xml "; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;------- it works but not change&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;&amp;nbsp;*file &amp;amp;path1.; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;----- DOESN'T WORK with macro &amp;amp;path1.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; %put &amp;amp;path1.; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt; &amp;nbsp;&amp;lt;------ &amp;amp;path1.=" '/directory /folder/office1.xml "&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT '&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT ' ';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT '&amp;lt;!DOCTYPE UPDATE SYSTEM "doc.dtd"&amp;gt;';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT ' ';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT '&amp;lt;DOC&amp;gt;';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT '&amp;nbsp;&amp;nbsp; &amp;lt;JOB&amp;gt;';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; line = '&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;APP FROM="'|| trim(&amp;amp;off) || '/&amp;gt;';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT line;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT '&amp;nbsp;&amp;nbsp; &amp;lt;/JOB&amp;gt;';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; PUT '&amp;lt;/DOC&amp;gt;';&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%MEND &lt;EM&gt;CREA_XML&amp;nbsp;&lt;/EM&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SET dataset;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%LET off = office;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; path =&amp;nbsp;cat('"',"'",'&lt;SPAN&gt;/directory /folder/&lt;/SPAN&gt;',strip(&amp;amp;off.),'.xml"');&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %LET path1 = path;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;STRONG&gt; &amp;nbsp; &amp;nbsp; &lt;EM&gt;&amp;nbsp;%CREA_XML;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a &lt;U&gt;new .xml document&lt;/U&gt;, in the path&amp;nbsp;&lt;STRONG&gt; '/directory /folder/&lt;/STRONG&gt;, &lt;U&gt;for each office,&lt;/U&gt; so I build the path by concatenating the office in a loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I check how is the path in %CREA_XML, it is correct, but &lt;STRONG&gt;with FILE &amp;amp;path1. it doesn't write anything&lt;/STRONG&gt;. However, If i write all path (the same value that is inside the %path1.) it works. So..I am not able to dynamize it!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help me? I don't know why it is happening.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&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>Tue, 20 Sep 2016 10:10:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-dynamical-path-for-FILE-command/m-p/299472#M63174</guid>
      <dc:creator>MissConde</dc:creator>
      <dc:date>2016-09-20T10:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to define a dynamical path for FILE command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-dynamical-path-for-FILE-command/m-p/299477#M63175</link>
      <description>&lt;P&gt;Here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;

       SET dataset;

       %LET off = office;
* this macro statement is dealt with before the data step is compiled;&lt;BR /&gt;
        path = cat('"',"'",'/directory /folder/',strip(&amp;amp;off.),'.xml"');
* this data step statement will create the data step variable path during data step execution!;&lt;BR /&gt;
        %LET path1 = path;
* this macro statement, again, will be dealt with BEFORE data step compilation, so &amp;amp;path1 will contain the text "path" instead of the contents of the data step variable, as this does not yet exist;&lt;BR /&gt;
         %CREA_XML;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You need to make clear to yourself that the macro engine is a pre-processor, designed to create dynamic program text. It is NOT meant to handle data!&lt;/P&gt;
&lt;P&gt;Avoid confusion by writing macro statements outside of data and proc steps, and only use macro &lt;U&gt;calls&lt;/U&gt; inside procs and data steps. That way you visualize that macro processing occurs BEFORE the resulting program text is fed to the main SAS interpreter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 07:30:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-dynamical-path-for-FILE-command/m-p/299477#M63175</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-20T07:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to define a dynamical path for FILE command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-dynamical-path-for-FILE-command/m-p/299479#M63176</link>
      <description>&lt;P&gt;If you want to define a dynamic file name from within the datastep, use the filevar= option in the FILE statement, and put your filename into the variable declared there. SAS will then automatically switch outfiles everytime the content of the "filevar" variable changes.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 07:34:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-dynamical-path-for-FILE-command/m-p/299479#M63176</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-20T07:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to define a dynamical path for FILE command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-dynamical-path-for-FILE-command/m-p/299480#M63177</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think that the problem is your macro variable path1. You could not introduce a variable content in a data step with a %let.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you do that, you are not putting office or path contents into macro variable, you are literaly putting &amp;nbsp;&amp;amp;off is replaced by office and &amp;amp;path1 by path.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%MACRO CREA_XML ;
        
*Create number of observations;
proc sql noprint;
	select count(*) into :_nobs
	from dataset;
quit;
%local i;
*For each observation:;
%do i=1 %to &amp;amp;_nobs;
	*Keep path;
	data _null_;
		set dataset;
		if _N_=&amp;amp;i.;
		path = cat('"',"'",'/directory /folder/',strip(office),'.xml"');
		call symput('path1',path);
		*this put the content of the last observation of path into macro
		variable path1;
	run;

	*And generate xml with this info;
	data _null_;
	       SET dataset;                      
	        file "&amp;amp;path1.";                                                                    
	        PUT '&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;';
	        PUT ' ';
	        PUT '&amp;lt;!DOCTYPE UPDATE SYSTEM "doc.dtd"&amp;gt;';
	        PUT ' ';
	        PUT '&amp;lt;DOC&amp;gt;';
	        PUT '   &amp;lt;JOB&amp;gt;';
	        line = '      &amp;lt;APP FROM="'|| trim(office) || '/&amp;gt;';
	        PUT line;
	        PUT '   &amp;lt;/JOB&amp;gt;';
	        PUT '&amp;lt;/DOC&amp;gt;';
	run;
%end;
%MEND CREA_XML ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Try something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 07:45:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-dynamical-path-for-FILE-command/m-p/299480#M63177</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2016-09-20T07:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to define a dynamical path for FILE command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-dynamical-path-for-FILE-command/m-p/299504#M63186</link>
      <description>&lt;P&gt;I think that maybe I have problems of concepts, that's true. But I've done %LET to be able to use these values in %MACRO. If I don't use %LET statement, the value of &lt;STRONG&gt;office&lt;/STRONG&gt; won't be visible in the %MACRO, am i wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact, I understand that you are explaining me that the value (using macro engine) is not "assign" until the data step ends..but my put &amp;amp;path1. has the value I expected! :S&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 10:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-dynamical-path-for-FILE-command/m-p/299504#M63186</guid>
      <dc:creator>MissConde</dc:creator>
      <dc:date>2016-09-20T10:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to define a dynamical path for FILE command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-dynamical-path-for-FILE-command/m-p/299509#M63187</link>
      <description>&lt;P&gt;First of all, your path name contains a blank and has an unbalanced single quote, which makes it impossible to execute your code for test at all.&lt;/P&gt;
&lt;P&gt;So I changed the path name to create a file in my typical location for SAS community tests:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO CREA_XML ;
        file "$HOME/sascommunity/office1.xml";
        *file &amp;amp;path1.;
        %put &amp;amp;path1.;
        PUT '&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;';
        PUT ' ';
        PUT '&amp;lt;!DOCTYPE UPDATE SYSTEM "doc.dtd"&amp;gt;';
        PUT ' ';
        PUT '&amp;lt;DOC&amp;gt;';
        PUT '   &amp;lt;JOB&amp;gt;';
        line = '      &amp;lt;APP FROM="'|| trim(&amp;amp;off) || '/&amp;gt;';
        PUT line;
        PUT '   &amp;lt;/JOB&amp;gt;';
        PUT '&amp;lt;/DOC&amp;gt;';
%MEND CREA_XML ;

data _null_;
%LET off = office;
path = "$HOME/sascommunity/&amp;amp;off..xml";
%LET path1 = path;
%CREA_XML;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The log from this looks like that&lt;/P&gt;
&lt;PRE&gt;16         %MACRO CREA_XML ;
17                 file "$HOME/sascommunity/office1.xml";
18                 *file &amp;amp;path1.;
19                 %put &amp;amp;path1.;
20                 PUT '&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;';
21                 PUT ' ';
22                 PUT '&amp;lt;!DOCTYPE UPDATE SYSTEM "doc.dtd"&amp;gt;';
23                 PUT ' ';
24                 PUT '&amp;lt;DOC&amp;gt;';
25                 PUT '   &amp;lt;JOB&amp;gt;';
26                 line = '      &amp;lt;APP FROM="'|| trim(&amp;amp;off) || '/&amp;gt;';
27                 PUT line;
28                 PUT '   &amp;lt;/JOB&amp;gt;';
29                 PUT '&amp;lt;/DOC&amp;gt;';
30         %MEND CREA_XML ;
31         
32         data _null_;
33         %LET off = office;
34         path = "$HOME/sascommunity/&amp;amp;off..xml";
35         %LET path1 = path;
36         %CREA_XML;
path
37         run;

NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
      36:1   
NOTE: Variable office is uninitialized.
NOTE: The file "$HOME/sascommunity/office1.xml" is:
      Filename=/home/e9782/sascommunity/office1.xml,
      Owner Name=e9782,Group Name=sasadmin,
      Access Permission=rw-r--r--,
      Last Modified=Tue Sep 20 12:38:47 2016

NOTE: 9 records were written to the file "$HOME/sascommunity/office1.xml".
      The minimum record length was 1.
      The maximum record length was 38.&lt;/PRE&gt;
&lt;P&gt;SAS complains about the unitialized variable probably because I omitted the set statement (I don't have your dataset), and I guess office is a variable in your dataset.&lt;/P&gt;
&lt;P&gt;Note that the result of the %put &amp;amp;path1. comes BEFORE any message created by the running datastep, and that &amp;amp;path1 obviously contains the text "path" (without the quotes).&lt;/P&gt;
&lt;P&gt;Now I changed the comments on the two FILE statements, and ran it again.&lt;/P&gt;
&lt;P&gt;What changes is that I now get&lt;/P&gt;
&lt;PRE&gt;ERROR: Physical file does not exist, 
       /usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/usr/dt/bin:/sbin:/usr/local/bin:/usr/java14_64/jre/bin:/usr/java14_64/bin.
&lt;/PRE&gt;
&lt;P&gt;which is a result of SAS trying to execute (in essence)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
file path;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as &amp;amp;path1 is replaced by the macro processor with the text "path" (without the quotes, of course).&lt;/P&gt;
&lt;P&gt;Since path is (at least in my installation) a default SAS file reference that points to the execution of the operating system's &lt;FONT face="courier new,courier"&gt;path&lt;/FONT&gt; command, the output of that command is used in the file statement, and that fails.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once again, all macro actions happen BEFORE the data step starts to run.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 10:51:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-dynamical-path-for-FILE-command/m-p/299509#M63187</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-20T10:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to define a dynamical path for FILE command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-dynamical-path-for-FILE-command/m-p/299579#M63203</link>
      <description>&lt;P&gt;Hi MissConde,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is easy and bears a lot of possibilities.&lt;/P&gt;&lt;P&gt;If you want to generate the path "on the fly" using the input from 'dataset'.&lt;/P&gt;&lt;P&gt;This is how to do it:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO CREA_XML(path=);
   DATA _NULL_;
      file "'&amp;amp;path.";                                                                                         
      PUT '&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;';
      PUT ' ';
      PUT '&amp;lt;!DOCTYPE UPDATE SYSTEM "doc.dtd"&amp;gt;';
      PUT ' ';
      PUT '&amp;lt;DOC&amp;gt;';
      PUT '   &amp;lt;JOB&amp;gt;';
      line = '      &amp;lt;APP FROM="'|| trim(&amp;amp;off) || '/&amp;gt;';
      PUT line;
      PUT '   &amp;lt;/JOB&amp;gt;';
      PUT '&amp;lt;/DOC&amp;gt;';
   RUN;
%MEND CREA_XML ;

%LET off = office;
data _null_;
   SET dataset;
   path = cats('/directory /folder/',"&amp;amp;off.",'.xml');
   call execute('%'||'CREA_XML(path='||strip(path)||');');
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;if you only want to create the xml once, just call&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%CREA_XML(path=/directory/folder/&amp;amp;off..xml);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Oligolas&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2016 15:22:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-define-a-dynamical-path-for-FILE-command/m-p/299579#M63203</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2016-09-20T15:22:21Z</dc:date>
    </item>
  </channel>
</rss>

