<?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: .csv file issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/csv-file-issue/m-p/593777#M170480</link>
    <description>&lt;P&gt;So you want to truncate the first column to only 10 characters and the last column to only 25 characters?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
 infile csv dsd truncover firstobs=2;
 row+1;
 do col=1 to 4 ;
   input value :$200. @;
   length=lengthn(value);
   output;
 end;
run;
proc means min max n mean ;
  class col;
  var length;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                        Analysis Variable : length

                  N
         col    Obs         Minimum         Maximum      N            Mean

           1     98       6.0000000      15.0000000     98       8.1530612

           2     98               0      20.0000000     98      12.0204082

           3     98               0      19.0000000     98      13.0306122

           4     98               0     114.0000000     98      43.9693878
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Oct 2019 15:27:03 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-10-03T15:27:03Z</dc:date>
    <item>
      <title>.csv file issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/csv-file-issue/m-p/593765#M170473</link>
      <description>&lt;P&gt;Good morning,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the attached .csv file that when I use proc import the column length are not coming up the way I want them. I need Agency Location Code (ALC) to be of a character of length 10, Order Tracking Number (ODN) to be a character of&amp;nbsp;length 17, Agency TAS to be a character of length 27 and Line of Accounting (LOA) to be a character of length 25. I do not to use the proc import.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-mauri&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 15:05:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/csv-file-issue/m-p/593765#M170473</guid>
      <dc:creator>mauri0623</dc:creator>
      <dc:date>2019-10-03T15:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: .csv file issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/csv-file-issue/m-p/593768#M170475</link>
      <description>&lt;P&gt;Why are you using PROC IMPORT to read a text file?&lt;/P&gt;
&lt;P&gt;Just write a data step to read the text file.&amp;nbsp; If you have no idea how to start use the code that PROC IMPORT generates (but know that it is much longer, confusing and uglier than code you would create yourself.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why not start by looking at the file?&lt;/P&gt;
&lt;PRE&gt;366   options generic;
367   data _null_;
368     infile csv obs=3;
369     input;
370     list;
371   run;

NOTE: The infile CSV is:
      (system-specific pathname),
      (system-specific file attributes)

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+--
1         Agency Location Code (ALC),Order Tracking Number (ODN),Agency TAS,Line of Accounting (LOA) 90
2         00008522,DCAAHAA23H20PSI,, 26
3         00006551,,097 X4930005,9797XXXX4930005 20202020 49305L2P NOH H5IN ZHSG 2539D02 20GA00000000 DFAS
      98  RNJ00 16000000000000 033186 NOHH520MI101 137
NOTE: 3 records were read from the infile (system-specific pathname).
      The minimum record length was 26.
      The maximum record length was 137.
&lt;/PRE&gt;
&lt;P&gt;In general writing code to read a CSV is easier than running PROC IMPORT and dealing with the mess it creates.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Especially when the file only has FOUR variables!&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile csv dsd truncover firstobs=2;
  input ALC :$10. ODN :$17. TAS :$27. LOA :$25.;
  label ALC='Agency Location Code (ALC)'
        ODN='Order Tracking Number (ODN)'
        TAS='Agency TAS'
        LOA='Line of Accounting (LOA)'
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 15:19:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/csv-file-issue/m-p/593768#M170475</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-03T15:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: .csv file issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/csv-file-issue/m-p/593774#M170479</link>
      <description>&lt;P&gt;Look in the log after the import. Take the code form there and fix it as needed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, it's overkill and has too much extra stuff but it's the easiest way when you're just getting started.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/181538"&gt;@mauri0623&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Good morning,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the attached .csv file that when I use proc import the column length are not coming up the way I want them. I need Agency Location Code (ALC) to be of a character of length 10, Order Tracking Number (ODN) to be a character of&amp;nbsp;length 17, Agency TAS to be a character of length 27 and Line of Accounting (LOA) to be a character of length 25. I do not to use the proc import.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-mauri&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 15:20:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/csv-file-issue/m-p/593774#M170479</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-03T15:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: .csv file issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/csv-file-issue/m-p/593777#M170480</link>
      <description>&lt;P&gt;So you want to truncate the first column to only 10 characters and the last column to only 25 characters?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
 infile csv dsd truncover firstobs=2;
 row+1;
 do col=1 to 4 ;
   input value :$200. @;
   length=lengthn(value);
   output;
 end;
run;
proc means min max n mean ;
  class col;
  var length;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                        Analysis Variable : length

                  N
         col    Obs         Minimum         Maximum      N            Mean

           1     98       6.0000000      15.0000000     98       8.1530612

           2     98               0      20.0000000     98      12.0204082

           3     98               0      19.0000000     98      13.0306122

           4     98               0     114.0000000     98      43.9693878
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 15:27:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/csv-file-issue/m-p/593777#M170480</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-03T15:27:03Z</dc:date>
    </item>
  </channel>
</rss>

