<?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: DI Studio - Creating a file on the fly in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/DI-Studio-Creating-a-file-on-the-fly/m-p/202771#M4481</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With DI Studio you need to create SAS Metadata.&lt;/P&gt;&lt;P&gt;- Table metadata for your source from a data base&lt;/P&gt;&lt;P&gt;- External file metadata for your extract file&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the File Writer transformation to create the output. &lt;/P&gt;&lt;P&gt;Define the External File metadata with a filename containing a macro variable (or macro level function) as part of the file name (this allows you to have a single metadata object writing to different physical files).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You don't need to pre-create an empty file. SAS will do this for you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Mar 2015 07:40:24 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2015-03-17T07:40:24Z</dc:date>
    <item>
      <title>DI Studio - Creating a file on the fly</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DI-Studio-Creating-a-file-on-the-fly/m-p/202769#M4479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to create a process that creates a file daily and outputs it to a file system to be consumed by another process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The file name must be in the format filename_timestamp and the data source is table in some sql server database. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Being new to DI Studio my assumption that it would be a customer stored process that would;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create the file&lt;/P&gt;&lt;P&gt;2. select from the table &lt;/P&gt;&lt;P&gt;3. write to file&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have figured out how to write to a file without issue but&amp;nbsp; i need to pre define and create the file manually before i run the job.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 22:23:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DI-Studio-Creating-a-file-on-the-fly/m-p/202769#M4479</guid>
      <dc:creator>goitzy</dc:creator>
      <dc:date>2015-03-16T22:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: DI Studio - Creating a file on the fly</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DI-Studio-Creating-a-file-on-the-fly/m-p/202770#M4480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With SAS code you would write something like this:&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13.3333330154419px;"&gt;%let timestamp=%sysfunc(date(),yymmddn8.);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set myLib.myTable;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file "C:\temp\&lt;STRONG&gt;myFileName_&amp;amp;timestamp&lt;/STRONG&gt;";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put Col1 Col2 Col3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Within DI Studio first you create a File object that has a parameter, then you create a job object that has a parameter:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Define the metadata for the file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - New -&amp;gt;External File -&amp;gt; Delimited (or Fixed)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp; Specify the file Metadata Name, for example: myFileName&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Specify the file physical location and name, for example: C:\temp\&lt;STRONG&gt;myFileName_&amp;amp;&lt;EM&gt;timestamp&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Under Advanced - File Name Quoting specify "&lt;STRONG&gt;Double quotes around the file&lt;/STRONG&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Under &lt;STRONG&gt;Parameters&lt;/STRONG&gt; specify a &lt;STRONG&gt;New Prompt&lt;/STRONG&gt;:&amp;nbsp;&amp;nbsp; the name is important. For example: &lt;EM&gt;&lt;STRONG&gt;timestamp&amp;nbsp; &lt;/STRONG&gt;&lt;/EM&gt;, maybe you can specify a default value&amp;nbsp; (Observe, that at this point, the icon of the file object changes. Now it has an &amp;amp; sign. )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The rest is as usual&lt;/P&gt;&lt;P&gt;The file object that you created does not reference a single physical file anymore. It represents a group of files: all files, that start with C:\temp\myFileName_&amp;nbsp; and end with a timestamp. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Create a job&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - The diagram should contain the data source, a File Writer transformation, the File object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Look at the Properties of the job and select &lt;STRONG&gt;Parameters&lt;/STRONG&gt;. Here, you could define the same parameter, but it is better to import the previous definition: Click on Import Parameters (Observe, that the jobs icon has an &amp;amp; now.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Click on the Precode and Postcoe and type specify the Precode, that creates the timestamp parameter (macro variable). For example: &lt;STRONG&gt;%let &lt;EM&gt;timestamp&lt;/EM&gt;=%sysfunc(date(),yymmddn8.);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Run the job&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 00:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DI-Studio-Creating-a-file-on-the-fly/m-p/202770#M4480</guid>
      <dc:creator>gergely_batho</dc:creator>
      <dc:date>2015-03-17T00:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: DI Studio - Creating a file on the fly</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DI-Studio-Creating-a-file-on-the-fly/m-p/202771#M4481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With DI Studio you need to create SAS Metadata.&lt;/P&gt;&lt;P&gt;- Table metadata for your source from a data base&lt;/P&gt;&lt;P&gt;- External file metadata for your extract file&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the File Writer transformation to create the output. &lt;/P&gt;&lt;P&gt;Define the External File metadata with a filename containing a macro variable (or macro level function) as part of the file name (this allows you to have a single metadata object writing to different physical files).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You don't need to pre-create an empty file. SAS will do this for you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 07:40:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DI-Studio-Creating-a-file-on-the-fly/m-p/202771#M4481</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-03-17T07:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: DI Studio - Creating a file on the fly</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DI-Studio-Creating-a-file-on-the-fly/m-p/202772#M4482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank You!!! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your instructions were awesome ... that's exactly what i needed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 15:44:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DI-Studio-Creating-a-file-on-the-fly/m-p/202772#M4482</guid>
      <dc:creator>goitzy</dc:creator>
      <dc:date>2015-03-18T15:44:40Z</dc:date>
    </item>
  </channel>
</rss>

