<?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 Need to import files with a particular delimiter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-to-import-files-with-a-particular-delimiter/m-p/738505#M230378</link>
    <description>Hi All,&lt;BR /&gt;I hope you all are safe and healthy in these tough situations.&lt;BR /&gt;&lt;BR /&gt;I am working on a task where i have to import a series of files (for ex- A1-A12) .&lt;BR /&gt;Now the issue with importing these series of files is , I only want to import files that are comma separated and not tab delimited in this series and i am not sure how to do that because those tab delimited files fall under the series.&lt;BR /&gt;&lt;BR /&gt;Need help on this.&lt;BR /&gt;&lt;BR /&gt;Thank you in advance&lt;BR /&gt;</description>
    <pubDate>Mon, 03 May 2021 07:17:27 GMT</pubDate>
    <dc:creator>Nimish28</dc:creator>
    <dc:date>2021-05-03T07:17:27Z</dc:date>
    <item>
      <title>Need to import files with a particular delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-import-files-with-a-particular-delimiter/m-p/738505#M230378</link>
      <description>Hi All,&lt;BR /&gt;I hope you all are safe and healthy in these tough situations.&lt;BR /&gt;&lt;BR /&gt;I am working on a task where i have to import a series of files (for ex- A1-A12) .&lt;BR /&gt;Now the issue with importing these series of files is , I only want to import files that are comma separated and not tab delimited in this series and i am not sure how to do that because those tab delimited files fall under the series.&lt;BR /&gt;&lt;BR /&gt;Need help on this.&lt;BR /&gt;&lt;BR /&gt;Thank you in advance&lt;BR /&gt;</description>
      <pubDate>Mon, 03 May 2021 07:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-import-files-with-a-particular-delimiter/m-p/738505#M230378</guid>
      <dc:creator>Nimish28</dc:creator>
      <dc:date>2021-05-03T07:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: Need to import files with a particular delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-import-files-with-a-particular-delimiter/m-p/738508#M230379</link>
      <description>&lt;P&gt;Based on the very thin information you share:&lt;/P&gt;
&lt;P&gt;Using a data step you could check in the first line of your data if there is a tab and only proceed with the import if there isn't one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 07:49:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-import-files-with-a-particular-delimiter/m-p/738508#M230379</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-05-03T07:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need to import files with a particular delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-import-files-with-a-particular-delimiter/m-p/738510#M230381</link>
      <description>Hi Patrick,&lt;BR /&gt;&lt;BR /&gt;I am using a datastep only and the importing text files from the desired folder.&lt;BR /&gt;Infile "path/*.txt "is the path i am using to get all the txt files from the folder but in between these txt files two txt files are tab delimited and i need to skip them while importing and i would really appreciate if you can explain how are you expecting me check the first line to filter out the files.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Mon, 03 May 2021 07:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-import-files-with-a-particular-delimiter/m-p/738510#M230381</guid>
      <dc:creator>Nimish28</dc:creator>
      <dc:date>2021-05-03T07:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need to import files with a particular delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-import-files-with-a-particular-delimiter/m-p/738568#M230410</link>
      <description>&lt;P&gt;In a data step it is easy to see if first record contains commas or tabs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data chartest;
   infile "your file goes here" obs=1 ;
   input;
   if index(_infile_,"09"X)&amp;gt;0 then &amp;lt;do something when tab is found&amp;gt;;
;&lt;/PRE&gt;
&lt;P&gt;Without see a lot more of your code, such as how you are getting the file names or reading the data I can't provide a lot of details of what the "do something" should be. A very likely option would be the STOP statement to end the execution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 12:37:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-import-files-with-a-particular-delimiter/m-p/738568#M230410</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-03T12:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need to import files with a particular delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-import-files-with-a-particular-delimiter/m-p/738580#M230418</link>
      <description>&lt;P&gt;Your problem description is missing a lot of pertinent issues.&lt;/P&gt;
&lt;P&gt;So let's assume that you want to run a single data step that reads all of the files using a wildcard in the INFILE statement.&lt;/P&gt;
&lt;P&gt;So first make sure you know how to tell which file you are reading (and so when you change files).&lt;/P&gt;
&lt;P&gt;When starting a new file check if the it is one you want to read or skip.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  length fname $256 ;
  infile "myfiles*.txt" filename=fname truncover dsd ;
  input @;
  if fname ne lag(fname) then do;
    if indexc(_infile_,'09'x) then skip=1;
    else skip=0;
  end;
  if not skip then do;
    input .... ;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the issue is that the data is same but sometimes they use tab and sometimes they use comma then you can just modify the value used by the DLM option of the infile statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  length dlm $1 ;
  infile "myfiles*.txt" truncover dsd dlm=dlm;
  input @;
  if indexc(_infile_,'09'x) then dlm='09'x;
  else dlm=',';
  input .... ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 May 2021 13:16:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-import-files-with-a-particular-delimiter/m-p/738580#M230418</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-03T13:16:49Z</dc:date>
    </item>
  </channel>
</rss>

