<?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 Writing the name of the file to the output dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Writing-the-name-of-the-file-to-the-output-dataset/m-p/942290#M369512</link>
    <description>&lt;P&gt;I am reading several files into 1 dataset, using a wildcard for the last 8 positions. Now I want to determine these 8 positions, to be also written to my output.&lt;/P&gt;&lt;P&gt;My input files are:&lt;/P&gt;&lt;P&gt;payments_20240110 payments_20240209 payments_20240309 etc ...&lt;/P&gt;&lt;P&gt;So my code is:&lt;/P&gt;&lt;P&gt;data overview;&lt;/P&gt;&lt;P&gt;set payments:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;How do I add a column 'payment_date' to my output? I have been struggling with 'SCAN' function, but I don't get it...&lt;/P&gt;</description>
    <pubDate>Tue, 03 Sep 2024 13:42:37 GMT</pubDate>
    <dc:creator>WimWeyers</dc:creator>
    <dc:date>2024-09-03T13:42:37Z</dc:date>
    <item>
      <title>Writing the name of the file to the output dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-the-name-of-the-file-to-the-output-dataset/m-p/942290#M369512</link>
      <description>&lt;P&gt;I am reading several files into 1 dataset, using a wildcard for the last 8 positions. Now I want to determine these 8 positions, to be also written to my output.&lt;/P&gt;&lt;P&gt;My input files are:&lt;/P&gt;&lt;P&gt;payments_20240110 payments_20240209 payments_20240309 etc ...&lt;/P&gt;&lt;P&gt;So my code is:&lt;/P&gt;&lt;P&gt;data overview;&lt;/P&gt;&lt;P&gt;set payments:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;How do I add a column 'payment_date' to my output? I have been struggling with 'SCAN' function, but I don't get it...&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2024 13:42:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-the-name-of-the-file-to-the-output-dataset/m-p/942290#M369512</guid>
      <dc:creator>WimWeyers</dc:creator>
      <dc:date>2024-09-03T13:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: Writing the name of the file to the output dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-the-name-of-the-file-to-the-output-dataset/m-p/942293#M369513</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/469101"&gt;@WimWeyers&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p00hxg3x8lwivcn1f0e9axziw57y.htm#p1hvkihxy1eushn1jwkb0ups79l1" target="_blank" rel="noopener"&gt;INDSNAME= option&lt;/A&gt; of the SET statement stores the dataset name (including the libref, e.g., "WORK") in a temporary variable from which you can extract the date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#808080"&gt;data overview;
set payments: &lt;FONT color="#000000"&gt;&lt;STRONG&gt;indsname=dsn&lt;/STRONG&gt;;&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;payment_date=input(scan(dsn,2,'_'),yymmdd8.);&lt;/FONT&gt;
&lt;FONT color="#000000"&gt;format payment_date yymmdd10.;&lt;/FONT&gt;
run;&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Sep 2024 14:03:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-the-name-of-the-file-to-the-output-dataset/m-p/942293#M369513</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-09-03T14:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Writing the name of the file to the output dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-the-name-of-the-file-to-the-output-dataset/m-p/942294#M369514</link>
      <description>&lt;P&gt;Please show the EXACT code that are using to read this with wildcards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this involves reading external files then the INFILE option FILENAME= would create a temporary variable holding the name of the current file being read and could be parsed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are combining data sets by using multiple names of the sets on the SET statement then the INDSNAME= option creates a temporary variable holding the name of the contributing data set that can be parsed.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2024 14:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-the-name-of-the-file-to-the-output-dataset/m-p/942294#M369514</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-09-03T14:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Writing the name of the file to the output dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-the-name-of-the-file-to-the-output-dataset/m-p/942295#M369515</link>
      <description>INDSNAME = works perfectly! Thank you both.</description>
      <pubDate>Tue, 03 Sep 2024 14:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-the-name-of-the-file-to-the-output-dataset/m-p/942295#M369515</guid>
      <dc:creator>WimWeyers</dc:creator>
      <dc:date>2024-09-03T14:11:06Z</dc:date>
    </item>
  </channel>
</rss>

