<?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: how to read in CSV file with one column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-in-CSV-file-with-one-column/m-p/786219#M250988</link>
    <description>&lt;P&gt;hi Reeza:&lt;/P&gt;&lt;P&gt;that is a great solution and explanation and it worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks so much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*===================*/&lt;/P&gt;&lt;P&gt;filename myfile&amp;nbsp; "C;\test.cs"&amp;nbsp; lrecl=10000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc import datafile=myfile&lt;BR /&gt;out=want&lt;/P&gt;&lt;P&gt;/*****&lt;SPAN&gt;DBMS= specifies that the input file is a delimited external file.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If a ASCII file is delimited by other than a space, you need to explicitly specify delimiter using DELIMITER (or DLM) option with using various characters or combinations of characters as a delimiter. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;DLM='09'x for Tab, DLM='&amp;amp;' for ampersand , DLM='^' for caret, delimiter="|" for pipe which is&amp;nbsp; a space delimited ASCII text file,*****&lt;/SPAN&gt;*/&lt;BR /&gt;dbms=dlm&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;replace;&lt;BR /&gt;delimiter='|';&amp;nbsp; /*specify here the delimiter*/&lt;BR /&gt;guessingrows=max;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*added to make the same format of DATE variable */&lt;/P&gt;&lt;P&gt;data want2;&lt;BR /&gt;set want ;&lt;BR /&gt;format Date e8601dt19.;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/***please see the difference***/&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="purpleclothlady_0-1639591903067.png" style="width: 594px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66779i5D1ABBF3ECA9F847/image-dimensions/594x265?v=v2" width="594" height="265" role="button" title="purpleclothlady_0-1639591903067.png" alt="purpleclothlady_0-1639591903067.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Dec 2021 18:13:24 GMT</pubDate>
    <dc:creator>purpleclothlady</dc:creator>
    <dc:date>2021-12-15T18:13:24Z</dc:date>
    <item>
      <title>how to read in CSV file with one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-in-CSV-file-with-one-column/m-p/786213#M250986</link>
      <description>&lt;P&gt;hi all:&lt;/P&gt;&lt;P&gt;I am trying to read in a CSV file with DLM="|" , there is only one column&lt;/P&gt;&lt;P&gt;but I would need to a SAS file with different columns&lt;/P&gt;&lt;P&gt;Question:&lt;/P&gt;&lt;P&gt;should I use data step or PROC import ?&lt;/P&gt;&lt;P&gt;thanks a ton.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*===please see the code ====*/&lt;/P&gt;&lt;P&gt;filename myfile "C:\test.csv" lrecl=10000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want2;&lt;BR /&gt;infile myfile dlm="|" dsd truncover firstobs=2;&lt;BR /&gt;input&lt;BR /&gt;STUDYID $&lt;BR /&gt;SUBJECT $&lt;BR /&gt;DEVICEID $&lt;BR /&gt;PLACE $&lt;BR /&gt;DATE&amp;nbsp; iso8601.&lt;BR /&gt;TOTALSITMIN&lt;BR /&gt;RUNMINUTES ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*========log error: ==========*/&lt;/P&gt;&lt;P&gt;NOTE: Invalid data for DATE in line 2 20-38.&lt;BR /&gt;NOTE: EQUAL SIGN not found.&lt;BR /&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0&lt;BR /&gt;2 001|20-1|C1| Wrist|2020-02-12T00:00:00|696|168| 47&lt;BR /&gt;STUDYID=001 SUBJECT=20-1 DEVICEID=C1 PLACE=Wrist DATE= INFORMAT= TOTALSITMIN=696 RUNMINUTES=168 _ERROR_=1 _N_=1&lt;BR /&gt;NOTE: Invalid data for DATE in line 3 20-38.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*===please see attached file&amp;nbsp; test.csv==*/&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;STUDYID|SUBJECT|DEVICEID|PLACE|DATE|TOTALSITMIN|RUNMINUTES|&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;001|20-1|C1| Wrist|2020-02-12T00:00:00|696|168|&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;001|21-5|C1| Wrist|2020-02-12T00:00:00||69|&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;001|25-5|C1||2020-02-12T00:00:00|1066|69|&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 15 Dec 2021 17:35:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-in-CSV-file-with-one-column/m-p/786213#M250986</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2021-12-15T17:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to read in CSV file with one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-in-CSV-file-with-one-column/m-p/786216#M250987</link>
      <description>CSV means comma (or semicolon) delimited file so you really have a text file with a pipe delimiter not a CSV file. &lt;BR /&gt;&lt;BR /&gt;I would recommend trying PROC IMPORT if you're having issues. &lt;BR /&gt;Then you can at least check the code generated in the log to see if it's close to yours or where it's different.&lt;BR /&gt;&lt;BR /&gt;proc import data=want2 datafile="C:\test.csv" dbms=dlm replace;&lt;BR /&gt;delimiter='|';&lt;BR /&gt;guessingrows=max;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Dec 2021 17:42:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-in-CSV-file-with-one-column/m-p/786216#M250987</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-15T17:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to read in CSV file with one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-in-CSV-file-with-one-column/m-p/786219#M250988</link>
      <description>&lt;P&gt;hi Reeza:&lt;/P&gt;&lt;P&gt;that is a great solution and explanation and it worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks so much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*===================*/&lt;/P&gt;&lt;P&gt;filename myfile&amp;nbsp; "C;\test.cs"&amp;nbsp; lrecl=10000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc import datafile=myfile&lt;BR /&gt;out=want&lt;/P&gt;&lt;P&gt;/*****&lt;SPAN&gt;DBMS= specifies that the input file is a delimited external file.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If a ASCII file is delimited by other than a space, you need to explicitly specify delimiter using DELIMITER (or DLM) option with using various characters or combinations of characters as a delimiter. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;DLM='09'x for Tab, DLM='&amp;amp;' for ampersand , DLM='^' for caret, delimiter="|" for pipe which is&amp;nbsp; a space delimited ASCII text file,*****&lt;/SPAN&gt;*/&lt;BR /&gt;dbms=dlm&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;replace;&lt;BR /&gt;delimiter='|';&amp;nbsp; /*specify here the delimiter*/&lt;BR /&gt;guessingrows=max;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*added to make the same format of DATE variable */&lt;/P&gt;&lt;P&gt;data want2;&lt;BR /&gt;set want ;&lt;BR /&gt;format Date e8601dt19.;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/***please see the difference***/&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="purpleclothlady_0-1639591903067.png" style="width: 594px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66779i5D1ABBF3ECA9F847/image-dimensions/594x265?v=v2" width="594" height="265" role="button" title="purpleclothlady_0-1639591903067.png" alt="purpleclothlady_0-1639591903067.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 18:13:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-in-CSV-file-with-one-column/m-p/786219#M250988</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2021-12-15T18:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to read in CSV file with one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-in-CSV-file-with-one-column/m-p/786222#M250989</link>
      <description>&lt;P&gt;There is no ISO informat, and even if there was I doubt it would allow reading of 8,601 bytes.&amp;nbsp; Looks like you want the E8610DT informat instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do not use FORMATTED input mode when reading a delimited file.&amp;nbsp;If you read a fixed number of bytes from the line you might:&lt;/P&gt;
&lt;P&gt;1) Read the delimiter in front of the value.&lt;/P&gt;
&lt;P&gt;2) Read the delimiter after the value and possibly part of the following value.&lt;/P&gt;
&lt;P&gt;3) Not read the full value, which could mess up this variable and reading of the next variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to include an informat specification in the INPUT statement then always include the : modifier so that the variable is read using LIST MODE so that the delimiters are honored.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input
  STUDYID $
  SUBJECT $
  DEVICEID $
  PLACE $
  DATE  :E8601DT.
  TOTALSITMIN
  RUNMINUTES 
;&lt;/CODE&gt;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 18:55:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-in-CSV-file-with-one-column/m-p/786222#M250989</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-15T18:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to read in CSV file with one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-in-CSV-file-with-one-column/m-p/786293#M251024</link>
      <description>&lt;P&gt;Hi Tom:&lt;/P&gt;&lt;P&gt;I updated the code per your suggestion and added format of DATE , here is the result. It works too.&lt;/P&gt;&lt;P&gt;thanks again.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/**====CODE====**/&lt;/P&gt;&lt;P&gt;filename myfile "C:\test.csv"&amp;nbsp; lrecl=10000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want2noformat;&lt;BR /&gt;infile myfile dlm="|" dsd truncover firstobs=2;&lt;BR /&gt;input&lt;BR /&gt;STUDYID $&lt;BR /&gt;SUBJECT $&lt;BR /&gt;DEVICEID $&lt;BR /&gt;PLACE $&lt;BR /&gt;DATE :E8601DT.&lt;BR /&gt;TOTALSITMIN&lt;BR /&gt;RUNMINUTES ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data wantfomat;&lt;BR /&gt;infile myfile dlm="|" dsd truncover firstobs=2;&lt;BR /&gt;input&lt;BR /&gt;STUDYID $&lt;BR /&gt;SUBJECT $&lt;BR /&gt;DEVICEID $&lt;BR /&gt;PLACE $&lt;BR /&gt;DATE :E8601DT.&lt;BR /&gt;TOTALSITMIN&lt;BR /&gt;RUNMINUTES ;&lt;BR /&gt;format date e8601dt.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="purpleclothlady_0-1639660815440.png" style="width: 515px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66789i222B786F252E6B47/image-dimensions/515x206?v=v2" width="515" height="206" role="button" title="purpleclothlady_0-1639660815440.png" alt="purpleclothlady_0-1639660815440.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 13:23:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-in-CSV-file-with-one-column/m-p/786293#M251024</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2021-12-16T13:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to read in CSV file with one column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-read-in-CSV-file-with-one-column/m-p/786351#M251056</link>
      <description>&lt;P&gt;Just to be clear that variable does not contain DATE values.&amp;nbsp; It contains &lt;STRONG&gt;DATETIME&lt;/STRONG&gt; values.&amp;nbsp; Using a variable name of DATE will likely cause confusion.&amp;nbsp; SAS stores dates as number of days and datetime as number of seconds.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Dec 2021 18:56:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-read-in-CSV-file-with-one-column/m-p/786351#M251056</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-16T18:56:09Z</dc:date>
    </item>
  </channel>
</rss>

