<?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: Reading CSV file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-CSV-file/m-p/65781#M14289</link>
    <description>I don't see any advantage to reading a field twice versus using the input or other functions to further process fields already read with "regular" delimited input.  But here is how you do it.  The COLUMN= infile statement option allows you to remember where the column pointer is.  &lt;BR /&gt;
&lt;BR /&gt;
In the program you can use COLUMN directly in the second input statement if you want too.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data have;&lt;BR /&gt;
   infile datalines dlm='|' dsd column=column;&lt;BR /&gt;
   input (a b)($) @;&lt;BR /&gt;
   col = column;&lt;BR /&gt;
   input (c1-c10) (@col $) d;&lt;BR /&gt;
   list;&lt;BR /&gt;
   datalines;&lt;BR /&gt;
a1|b_1|c1|100&lt;BR /&gt;
a2||c2|33&lt;BR /&gt;
a2||c2|22&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
    <pubDate>Thu, 11 Mar 2010 12:46:02 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2010-03-11T12:46:02Z</dc:date>
    <item>
      <title>Reading CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-CSV-file/m-p/65776#M14284</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Is it possible to read a column in a csv file more than once using the list input statement?&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Tue, 09 Mar 2010 02:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-CSV-file/m-p/65776#M14284</guid>
      <dc:creator>huikeng_sas</dc:creator>
      <dc:date>2010-03-09T02:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Reading CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-CSV-file/m-p/65777#M14285</link>
      <description>For whatever purpose, you might consider resetting the input offset pointer to the start of the record and re-read the fields again with alternate variable names.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
1    data _null_;&lt;BR /&gt;
2    infile datalines dsd dlm=',';&lt;BR /&gt;
3    length b x_b $20;&lt;BR /&gt;
4    input @;&lt;BR /&gt;
5    input a $ b $ @1 @;&lt;BR /&gt;
6    input x_a $ x_b $ @;&lt;BR /&gt;
7    input c $;&lt;BR /&gt;
8    putlog _all_;&lt;BR /&gt;
9    list;&lt;BR /&gt;
10   datalines;&lt;BR /&gt;
&lt;BR /&gt;
b=y12345678 x_b=y12345678 a=x x_a=x c=z _ERROR_=0 _N_=1&lt;BR /&gt;
RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+---&lt;BR /&gt;
11         x,y12345678,z&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
12   run</description>
      <pubDate>Tue, 09 Mar 2010 03:33:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-CSV-file/m-p/65777#M14285</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-03-09T03:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: Reading CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-CSV-file/m-p/65778#M14286</link>
      <description>Thanks Scotts for your prompt posting.&lt;BR /&gt;
&lt;BR /&gt;
However, if I have a csv file that contain 50 columns and I need to read the last 2 columns twice, is there a more efficient way than resetting the pointer to column 1?&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Tue, 09 Mar 2010 05:49:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-CSV-file/m-p/65778#M14286</guid>
      <dc:creator>huikeng_sas</dc:creator>
      <dc:date>2010-03-09T05:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: Reading CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-CSV-file/m-p/65779#M14287</link>
      <description>None I am aware of --- so, explain why this is necessary and maybe the forum subscribers can provide an alternative?  For example, input the last two columns using $CHAR and then use the INPUT function to convert the data-string to another format using a suitable INFORMAT with the INPUT function.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 09 Mar 2010 12:35:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-CSV-file/m-p/65779#M14287</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-03-09T12:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: Reading CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-CSV-file/m-p/65780#M14288</link>
      <description>That could be a possible workaround....thanks!</description>
      <pubDate>Thu, 11 Mar 2010 03:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-CSV-file/m-p/65780#M14288</guid>
      <dc:creator>huikeng_sas</dc:creator>
      <dc:date>2010-03-11T03:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Reading CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-CSV-file/m-p/65781#M14289</link>
      <description>I don't see any advantage to reading a field twice versus using the input or other functions to further process fields already read with "regular" delimited input.  But here is how you do it.  The COLUMN= infile statement option allows you to remember where the column pointer is.  &lt;BR /&gt;
&lt;BR /&gt;
In the program you can use COLUMN directly in the second input statement if you want too.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data have;&lt;BR /&gt;
   infile datalines dlm='|' dsd column=column;&lt;BR /&gt;
   input (a b)($) @;&lt;BR /&gt;
   col = column;&lt;BR /&gt;
   input (c1-c10) (@col $) d;&lt;BR /&gt;
   list;&lt;BR /&gt;
   datalines;&lt;BR /&gt;
a1|b_1|c1|100&lt;BR /&gt;
a2||c2|33&lt;BR /&gt;
a2||c2|22&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 11 Mar 2010 12:46:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-CSV-file/m-p/65781#M14289</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-03-11T12:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: Reading CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-CSV-file/m-p/65782#M14290</link>
      <description>Nice solution!&lt;BR /&gt;
&lt;BR /&gt;
Scott</description>
      <pubDate>Thu, 11 Mar 2010 14:05:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-CSV-file/m-p/65782#M14290</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-03-11T14:05:16Z</dc:date>
    </item>
  </channel>
</rss>

