<?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 put filename into the data using SAS-DI? in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-put-filename-into-the-data-using-SAS-DI/m-p/376416#M11450</link>
    <description>&lt;P&gt;I'm a new SAS's developer. I'm using SAS-DI to create a job. I need to put filename into a column of data because I create a job that read multiple input files and write it into a output file. The filename column will help to trackback to input file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to create a external file connect to file reader box. It look like below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10357i9810D53AE46D34DD/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="SAS.PNG" title="SAS.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In external file (INPUT FILE), I put additional options to keep filename into "infilename" variable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10360i2DD9E2FF2FA29B5D/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="SAS4.PNG" title="SAS4.PNG" /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In File Reader box, I put "infilename" variable into expression at the filename column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10358i5C564948DEEB4F52/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="SAS2.PNG" title="SAS2.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Running is pass but It error when I try to open output of File Reader box. The error message is "Unable to execute query: SQL passthru expression contained these errors: ERROR: The following columns were not found in the contributing tables: infilename."&lt;/P&gt;&lt;P&gt;Please advice me, How to put filename into the data using SAS-DI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10359iFC24CC25AFCD5934/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="SAS3.PNG" title="SAS3.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please advice me, How to put filename into the data using SAS-DI?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jul 2017 06:23:53 GMT</pubDate>
    <dc:creator>suttipop</dc:creator>
    <dc:date>2017-07-17T06:23:53Z</dc:date>
    <item>
      <title>How to put filename into the data using SAS-DI?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-put-filename-into-the-data-using-SAS-DI/m-p/376416#M11450</link>
      <description>&lt;P&gt;I'm a new SAS's developer. I'm using SAS-DI to create a job. I need to put filename into a column of data because I create a job that read multiple input files and write it into a output file. The filename column will help to trackback to input file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to create a external file connect to file reader box. It look like below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10357i9810D53AE46D34DD/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="SAS.PNG" title="SAS.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In external file (INPUT FILE), I put additional options to keep filename into "infilename" variable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10360i2DD9E2FF2FA29B5D/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="SAS4.PNG" title="SAS4.PNG" /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In File Reader box, I put "infilename" variable into expression at the filename column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10358i5C564948DEEB4F52/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="SAS2.PNG" title="SAS2.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Running is pass but It error when I try to open output of File Reader box. The error message is "Unable to execute query: SQL passthru expression contained these errors: ERROR: The following columns were not found in the contributing tables: infilename."&lt;/P&gt;&lt;P&gt;Please advice me, How to put filename into the data using SAS-DI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10359iFC24CC25AFCD5934/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="SAS3.PNG" title="SAS3.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please advice me, How to put filename into the data using SAS-DI?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 06:23:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-put-filename-into-the-data-using-SAS-DI/m-p/376416#M11450</guid>
      <dc:creator>suttipop</dc:creator>
      <dc:date>2017-07-17T06:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to put filename into the data using SAS-DI?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-put-filename-into-the-data-using-SAS-DI/m-p/376422#M11451</link>
      <description>&lt;P&gt;The automatically created variable from the filename= option cannot be included in the dataset. You have to assign its value to another variable in the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your question concerns DI Studio, I will move your post to the proper Data Management community.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 06:34:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-put-filename-into-the-data-using-SAS-DI/m-p/376422#M11451</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-17T06:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to put filename into the data using SAS-DI?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-put-filename-into-the-data-using-SAS-DI/m-p/376607#M11463</link>
      <description>It's not a ready made check box for this, but it can be accomplished in several ways.&lt;BR /&gt;How so you generate the file name, and what transformation(s) do you use?</description>
      <pubDate>Mon, 17 Jul 2017 15:19:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-put-filename-into-the-data-using-SAS-DI/m-p/376607#M11463</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-07-17T15:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to put filename into the data using SAS-DI?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-put-filename-into-the-data-using-SAS-DI/m-p/376612#M11465</link>
      <description>Sorry, didn't see the attached images.&lt;BR /&gt;Your problem is that the mapping occurs in a sub sequent SQL step, and I guess your INFILE optiona is not preserved there. Check the generated code to understand how things are executing.&lt;BR /&gt;&lt;BR /&gt;"FILENAME= variable is not written to the data set."&lt;BR /&gt;&lt;BR /&gt;I need to get home to my own SAS DIS for experimenting a bit...</description>
      <pubDate>Mon, 17 Jul 2017 15:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-put-filename-into-the-data-using-SAS-DI/m-p/376612#M11465</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-07-17T15:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to put filename into the data using SAS-DI?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-put-filename-into-the-data-using-SAS-DI/m-p/376873#M11469</link>
      <description>I didn't have time to experiment.  But one dirty trick would be to add an assignment statement in the INFILE options box, so the filename variable is preserved.&lt;BR /&gt;But still wonder how you set the physical file name in the first place. There are more elegant solutions if you have it as a parameter to the job, and a loop job in case of multiple files.</description>
      <pubDate>Tue, 18 Jul 2017 06:22:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-put-filename-into-the-data-using-SAS-DI/m-p/376873#M11469</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-07-18T06:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to put filename into the data using SAS-DI?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-put-filename-into-the-data-using-SAS-DI/m-p/376910#M11474</link>
      <description>&lt;P&gt;Added on 19 September 2017 by the author of below post:&lt;/P&gt;
&lt;P&gt;Below solution actually doesn't work because DIS will generate the length definition for _infilename AFTER variable _infilename has been used in &lt;EM&gt;filename=_infilename&lt;/EM&gt;. Because of this sequence &lt;EM&gt;_infilename&lt;/EM&gt; will actually get assigned a default and too short length. The SAS log will show the following Warning&lt;/P&gt;
&lt;PRE&gt;WARNING: Length of character variable _infilename has already been set. 
         Use the LENGTH statement as the very first statement in the DATA STEP to declare the length of a character variable.&lt;/PRE&gt;
&lt;P&gt;Refer to&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Data-Management/Adding-Multiple-Filenames-to-DI-Studio-Job/m-p/397083#M12052" target="_blank"&gt;https://communities.sas.com/t5/SAS-Data-Management/Adding-Multiple-Filenames-to-DI-Studio-Job/m-p/397083#M12052&lt;/A&gt; for solution options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154342"&gt;@suttipop&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;It's always worth to look into the generated code to understand why things are not working - and to get ideas what you could try to make it work.&lt;/P&gt;
&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;was hinting there is a "hack" option to make this work.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 415px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/10384i468C5E4D584E3638/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 599px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/10385i6D2E543261276B75/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you've done such a set-up look into the generated code to understand how this affected code generation.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 11:48:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-put-filename-into-the-data-using-SAS-DI/m-p/376910#M11474</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-09-19T11:48:26Z</dc:date>
    </item>
  </channel>
</rss>

