<?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 Proc import : Capture the date as a new column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-import-Capture-the-date-as-a-new-column/m-p/645297#M192878</link>
    <description>&lt;P&gt;Good Evening to all..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having a file "xxxx_20200101.xlsx" . This file contains prefix of xxx and with the date of file extraction as 20200101. i am using proc import to read this file and creating a new data set.&amp;nbsp;&lt;/P&gt;&lt;P&gt;While i am creating a new data set i need to capture this date(20200101) in an new column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ex:&lt;/P&gt;&lt;P&gt;Col_1&amp;nbsp; &amp;nbsp;Col_2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Col_3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; File_Date&lt;/P&gt;&lt;P&gt;01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xxxx&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; aaaa&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20200101&lt;/P&gt;&lt;P&gt;02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; yyyy&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bbbb&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20200101&lt;/P&gt;&lt;P&gt;03&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; zzzz&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cccc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20200101&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 May 2020 13:51:28 GMT</pubDate>
    <dc:creator>sarav93</dc:creator>
    <dc:date>2020-05-05T13:51:28Z</dc:date>
    <item>
      <title>Proc import : Capture the date as a new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-import-Capture-the-date-as-a-new-column/m-p/645297#M192878</link>
      <description>&lt;P&gt;Good Evening to all..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having a file "xxxx_20200101.xlsx" . This file contains prefix of xxx and with the date of file extraction as 20200101. i am using proc import to read this file and creating a new data set.&amp;nbsp;&lt;/P&gt;&lt;P&gt;While i am creating a new data set i need to capture this date(20200101) in an new column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ex:&lt;/P&gt;&lt;P&gt;Col_1&amp;nbsp; &amp;nbsp;Col_2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Col_3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; File_Date&lt;/P&gt;&lt;P&gt;01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xxxx&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; aaaa&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20200101&lt;/P&gt;&lt;P&gt;02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; yyyy&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bbbb&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20200101&lt;/P&gt;&lt;P&gt;03&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; zzzz&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cccc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20200101&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 13:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-import-Capture-the-date-as-a-new-column/m-p/645297#M192878</guid>
      <dc:creator>sarav93</dc:creator>
      <dc:date>2020-05-05T13:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Proc import : Capture the date as a new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-import-Capture-the-date-as-a-new-column/m-p/645306#M192881</link>
      <description>&lt;P&gt;Preferred: save the data to a csv (comma-separated) file from Excel, and use a data step to read it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let infile_date = 20200101;

data want;
infile "/..../xxx_&amp;amp;infile_date..csv";
input col_1 :$2. col_2 :$4. col_3 :$4.;
file_date = input("&amp;amp;infile_date",yymmdd8.);
format file_date yymmddd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or, if the unreliable Excel format is unescapable, set the additional variable in a follow-up data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let infile_date = 20200101;

proc import
  datafile="/..../xxx_&amp;amp;infile_date..xlsx"
  out=import
  dbms=xlsx
  replace
;
run;

data want;
set import;
file_date = input("&amp;amp;infile_date",yymmdd8.);
format file_date yymmddd10.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 May 2020 14:15:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-import-Capture-the-date-as-a-new-column/m-p/645306#M192881</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-05T14:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proc import : Capture the date as a new column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-import-Capture-the-date-as-a-new-column/m-p/645307#M192882</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327203"&gt;@sarav93&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am thinking about something like this (untested code)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myfile = "xxxx_20200101.xlsx";

proc import datafile=&amp;amp;myfile.
		    out=want
		    dbms=xlsx
		    replace;
run;

data want2;
	set want;
 	format File_Date YYMMDDn8.;
	File_Date = input(substr(&amp;amp;myfile,length(&amp;amp;myfile.)-12,8),YYMMDD8.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 14:24:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-import-Capture-the-date-as-a-new-column/m-p/645307#M192882</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-05-05T14:24:37Z</dc:date>
    </item>
  </channel>
</rss>

