<?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: Assigning a variable to macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assigning-a-variable-to-macro-variable/m-p/293989#M61307</link>
    <description>&lt;P&gt;Thanks a lot for your solution. It works great now.&lt;/P&gt;</description>
    <pubDate>Thu, 25 Aug 2016 12:00:36 GMT</pubDate>
    <dc:creator>jayakumarmm</dc:creator>
    <dc:date>2016-08-25T12:00:36Z</dc:date>
    <item>
      <title>Assigning a variable to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-a-variable-to-macro-variable/m-p/293878#M61248</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just want to assign a file path to FILENAME in the below code but I know I am doing some simple mistake to get the result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Actual issue:&lt;/STRONG&gt; Text2 variable value(Contains file path with name) need to assigned to macro variable, so that I can assign macro variable for FILENAME function for file path. But macro variable is not working in Filename function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    data testData;
      set ds2;
      text=cats(put(date,yymmn6.),put("W",1.),put(week,1.));
      text1=cats(put("Final_file_",12.),put(text,10.),put(".txt",5.));
      text2 = cats(put("""",1.),put("/path/Data_process/",50.),put("/",1.),put(text1,25.),put("""",1.));
      call symputx('nm_fl',put(text2,50.),'G');
    run;
    --------------------------------------------------------------
        %put &amp;amp;nm_fl;
        filename myfile &amp;amp;nm_fl1.;
    -----------------------------------------------------------------
        data "/pathsample_pipe_delimited_dataset";
      	infile myfile dlm='|' dsd FIRSTOBS=2;
      	input FIELD1 $ FIELD2;
      	format FIELD2; 30.;
    	run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Aug 2016 22:07:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-a-variable-to-macro-variable/m-p/293878#M61248</guid>
      <dc:creator>jayakumarmm</dc:creator>
      <dc:date>2016-08-24T22:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning a variable to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-a-variable-to-macro-variable/m-p/293881#M61250</link>
      <description>&lt;P&gt;There is absolutely no need to include put and a format in your CAT function calls when a variable is not involved. Make sure that the formats match the variable type or unexpected results may occur.&lt;/P&gt;
&lt;P&gt;You should show the log and the likely errors generated:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; text1=cats(put("Final_file_",12.),put(text,10.),pu​t(".txt",5.));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since&amp;nbsp;"final_file_" is literal text Put using a&amp;nbsp;12. format&amp;nbsp;is wrong as 12. is for numeric&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;      text=cats(put(date,yymmn6.),"W",put(week,1​.));
      text1=cats("Final_file_",text,".txt");
      text2 = cats('"/path/Data_process/',text1,'"');
      call symputx('nm_fl',text2,'G');
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;may be a bit closer to what you want. And did you really want 2 / next to each other in text2?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Generally I avoid actually placing quotes inside of macro variables as it seems the results are more fragile.&lt;/P&gt;
&lt;P&gt;Did you try %Put &amp;amp;nm_fl to see what the variable resolved to?&lt;/P&gt;
&lt;P&gt;Also, is there more than one record in your dataset DS2? If so, you are only going to get one macro variable for the last record as a result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note that&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="2"&gt;data&lt;/FONT&gt; &lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;"/pathsample_pipe_delimited_dataset"&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;is possibly going to have an issue with the length of the name besides the poor idea of the "name literal"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 15:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-a-variable-to-macro-variable/m-p/293881#M61250</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-25T15:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning a variable to macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assigning-a-variable-to-macro-variable/m-p/293989#M61307</link>
      <description>&lt;P&gt;Thanks a lot for your solution. It works great now.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2016 12:00:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assigning-a-variable-to-macro-variable/m-p/293989#M61307</guid>
      <dc:creator>jayakumarmm</dc:creator>
      <dc:date>2016-08-25T12:00:36Z</dc:date>
    </item>
  </channel>
</rss>

