<?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 txt file into SAS table why I always have problem in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871482#M38609</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/442039"&gt;@V168&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your fast reply. Here I attached the split file, can you tell me the code to read the file.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can do it yourself.&amp;nbsp; The file appears to have exactly the fields I identified before.&amp;nbsp; Only the actual column numbers are slightly different.&lt;/P&gt;
&lt;PRE&gt;----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9--
1176914599423 10/04/1999 10/15/1999     NEED        1        1  A1       45    AB     $72.00&lt;/PRE&gt;
&lt;P&gt;So the first field is in columns 1 to 13.&amp;nbsp; It looks like an identifier, so read it has CHARACTER even though it only contains digits.&lt;/P&gt;
&lt;P&gt;Then there are 2 date fields that are each 10 characters long at columns 15 and 26.&lt;/P&gt;
&lt;P&gt;Then that status field or whatever it is that is in columns 41 to 44.&lt;/P&gt;
&lt;P&gt;Then there are one character fields in column 53 and 62 and&amp;nbsp;two character fields in columns 65-66, 74-75 and 81-82.&amp;nbsp; Some of them only have digits so they could be read as numbers.&amp;nbsp; You will need to know what the strings mean to decide if it makes sense to treat them as a number or a string.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And finally the dollar amount at the end in columns 82 to 92.&amp;nbsp; So read it from column 82 using COMMA informat with a width of 11.&lt;/P&gt;</description>
    <pubDate>Mon, 24 Apr 2023 02:55:19 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-04-24T02:55:19Z</dc:date>
    <item>
      <title>how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871460#M38600</link>
      <description>&lt;P&gt;Hi there:&lt;/P&gt;&lt;P&gt;I am new sas user. I am doing a project.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Objective:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The attached data is the CRM data of a wireless company for 2 years. The wireless&lt;/P&gt;&lt;P&gt;company would like to investigate the customer distribution and business behaviors, and&lt;/P&gt;&lt;P&gt;then gain insightful understanding about the customers, and to forecast the deactivation&lt;/P&gt;&lt;P&gt;trends for the next 6 months.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Data:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Acctno: account number.&lt;/P&gt;&lt;P&gt;Actdt: account activation date&lt;/P&gt;&lt;P&gt;Deactdt: account deactivation date&lt;/P&gt;&lt;P&gt;DeactReason: reason for deactivation.&lt;/P&gt;&lt;P&gt;GoodCredit: customer’s credit is good or not.&lt;/P&gt;&lt;P&gt;RatePlan: rate plan for the customer.&lt;/P&gt;&lt;P&gt;DealerType: dealer type.&lt;/P&gt;&lt;P&gt;Age: customer age.&lt;/P&gt;&lt;P&gt;Province: province.&lt;/P&gt;&lt;P&gt;Sales: the amount of sales to a customer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the first three line of data is like this:&lt;/P&gt;&lt;P&gt;1176913194483 06/20/1999&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; A1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;58&amp;nbsp; &amp;nbsp; BC&amp;nbsp; &amp;nbsp; $128.00&lt;BR /&gt;1176914599423 10/04/1999 10/15/1999&amp;nbsp; &amp;nbsp; &amp;nbsp;NEED&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 A1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 45&amp;nbsp; &amp;nbsp; AB&amp;nbsp; &amp;nbsp; &amp;nbsp;$72.00&lt;BR /&gt;1176951913656 07/01/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 A1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 57&amp;nbsp; &amp;nbsp; BC&amp;nbsp; &amp;nbsp; &amp;nbsp;$593.00&lt;/P&gt;&lt;P&gt;when I try to use the code to read the file into sas table, always give me proble, I want to get help how to read the file proberly.I use sas 9.4. my code is:&lt;/P&gt;&lt;P&gt;data telecom;&lt;BR /&gt;infile '\My file path\' dlm=' ';&lt;BR /&gt;length Acctno $12 Actdt 10 Deactdt 10 DeactReason $8 GoodCredit 8 RatePlan $8 DealerType $2 Age 8 Province $2 Sales 8;&lt;BR /&gt;format Actdt Deactdt date9. Sales dollar8.2;&lt;BR /&gt;input Acctno Actdt mmddyy10. Deactdt mmddyy10. DeactReason GoodCredit RatePlan DealerType Age Province Sales dollar8.2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2023 20:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871460#M38600</guid>
      <dc:creator>V168</dc:creator>
      <dc:date>2023-04-23T20:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871463#M38601</link>
      <description>&lt;P&gt;When I copied your example lines and pasted it into the program editor I got this garbled file.&lt;/P&gt;
&lt;PRE&gt;1176913194483 06/20/1999                                          0        1  A1       58    BC    $128.00
1176914599423 10/04/1999 10/15/1999     NEED        1        1 A1        45    AB     $72.00
1176951913656 07/01/2000                                          0        1 A1        57    BC     $593.00&lt;/PRE&gt;
&lt;P&gt;So it is NOT a delimited file and NOT a fixed position file either.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps the forum editor just garbled the file.&amp;nbsp; Show the example lines using the POP-UP window that appears when you click on the Insert Code icon.&amp;nbsp; That will prevent the forum editor from re-flowing the lines into paragraphs.&lt;/P&gt;
&lt;P&gt;Does your actual file look like this? With fixed positions for the columns of data?&lt;/P&gt;
&lt;PRE&gt;1176913194483 06/20/1999                                          0        1  A1        58    BC    $128.00
1176914599423 10/04/1999 10/15/1999     NEED                      1        1  A1        45    AB     $72.00
1176951913656 07/01/2000                                          0        1  A1        57    BC    $593.00&lt;/PRE&gt;
&lt;P&gt;If so then you will want to use COLUMN MODE or FORMATTED MODE (or a combination of both) to read the variables from the lines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To see the column positions you can try using the LIST statement in a data step. You might start by just looking at the first 10 lines.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile '/My_file_directory/my_filename.my_extension' obs=10;
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Has some thing accidentally inserted TAB characters in place of some of the spaces in the file?&amp;nbsp; You might want to try using the EXPANDTABS option on the INFILE statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the file does not have the data in fixed columns then you cannot use SPACE as the delimiter to treat it as a delimited file because you clearly have multiple spaces between the fields in some of the lines.&amp;nbsp; So instead you might be able to read it as a LIST MODE file, but that would required that the missing date fields have period to represent their position on the line.&lt;/P&gt;
&lt;P&gt;So perhaps something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1176913194483 06/20/1999          .        .                      0        1  A1        58    BC    $128.00
1176914599423 10/04/1999 10/15/1999     NEED                      1        1  A1        45    AB     $72.00
1176951913656 07/01/2000          .        .                      0        1  A1        57    BC    $593.00&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 23 Apr 2023 21:28:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871463#M38601</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-23T21:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871466#M38602</link>
      <description>&lt;P&gt;You need to read your log. If you do not understand what the log tells you then copy the text from the log and paste into a text box opened on the forum with the &amp;lt;/&amp;gt; icon that appears above the message window. Copy the code and all messages related to data step or procedure. The text box is important to preserve the diagnostic codes that SAS often provides.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Brief example using your code&lt;/P&gt;
&lt;PRE&gt;342  data telecom;
343  /*infile '\My file path\' dlm=' ';*/
344  length Acctno $12 Actdt 10 Deactdt 10 DeactReason $8 GoodCredit 8 RatePlan $8 DealerType $2
                             --         --
                             352        352
344! Age 8 Province $2 Sales 8;
&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;ERROR 352-185: The length of numeric variables is 3-8.&lt;/STRONG&gt;&lt;/FONT&gt;

345  format Actdt Deactdt date9. Sales dollar8.2;
346  input Acctno Actdt mmddyy10. Deactdt mmddyy10. DeactReason GoodCredit RatePlan DealerType Age
346!  Province Sales dollar8.2;
347  datalines;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TELECOM may be incomplete.  When this step was stopped there were 0
         observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

351  run;
&lt;/PRE&gt;
&lt;P&gt;Please paste example data from a text file into a text box as well. The message window has reformatted your text, or any edits you did, so that the rows you show now have TAB characters in them and possibly other artifacts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first problem is that you are using illegal syntax on the LENGTH statement. SAS finds that sort of error and stops.&lt;/P&gt;
&lt;P&gt;I notice when I count characters that your Acctno variable shows 13 characters in your example: 1176913194483. So the length you have assigned will truncate the last digit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your INFILE options are not set correctly to deal with missing values.&lt;/P&gt;
&lt;P&gt;You are attempting to use list input but two of your three example lines Deactdt and DeactReason are not present. So when the variables are not present they attempt to read other values. When you fix your LENGTH statement you should get a lot of invalid data notes because of this. The option that you likely need to add to your INFILE statement is DSD. That will treat two successive delimiters as indicating a missing value so the spaces are for missing are treated correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, when you specific an informat on the Input statement such as Deactdt mmddyy10. with a delimited file it is a good idea to use the : modifier, as in Deactdt :mmddyy10. so that short values don't cause problems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And lastly you might have an issue with the Dollar8.2 informat. If any of your values are missing the decimal place then the behavior SAS has for such is to imply a decimal point. Just use Dollar8. and things will be fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example of this behavior. You can copy this code into your SAS editor and run it. You will see that the first 4 rows are treated as likely intended because there is a decimal in the value even if there is nothing to the right of it. But the last row is read as 1.23 because it has no decimal and the Informat you specified as Dollar8.2 implied one. Change the Informat to Dollar8. and the behavior is as expected.&lt;/P&gt;
&lt;PRE&gt;data junk;
   input amount dollar8.2;
   format amount dollar8.2;
datalines;
$123.45
$123.00
123.0
123.
$123
;&lt;/PRE&gt;
&lt;P&gt;This actually is a hold over feature from the days of punch cards for data entry. The limited number of columns meant that fixed decimal places, such as in currency did not have to actually punch that character saving space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2023 21:45:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871466#M38602</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-04-23T21:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871475#M38604</link>
      <description>&lt;P&gt;thanks&amp;nbsp; I run the code and get this result&lt;/P&gt;&lt;P&gt;NOTE: The infile 'D:\Metro College class\Advanced SAS\Mini Project\New_Wireless_Fixed.txt' is:&lt;BR /&gt;Filename=D:\Metro College class\Advanced SAS\Mini Project\New_Wireless_Fixed.txt,&lt;BR /&gt;RECFM=V,LRECL=32767,File Size (bytes)=9611970,&lt;BR /&gt;Last Modified=April 04, 2023 21:51:23,&lt;BR /&gt;Create Time=April 04, 2023 21:51:21&lt;/P&gt;&lt;P&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+---&lt;BR /&gt;1 1176913194483 06/20/1999 0 1 A1 58 BC $12&lt;BR /&gt;89 8.00 92&lt;BR /&gt;2 1176914599423 10/04/1999 10/15/1999 NEED 1 1 A1 45 AB $7&lt;BR /&gt;89 2.00 92&lt;BR /&gt;3 1176951913656 07/01/2000 0 1 A1 57 BC $59&lt;BR /&gt;89 3.00 92&lt;BR /&gt;4 1176954000288 05/30/2000 1 2 A1 47 ON $8&lt;BR /&gt;89 3.00 92&lt;BR /&gt;5 1176969186303 12/13/2000 1 1 C1 82 BC&lt;BR /&gt;89 92&lt;BR /&gt;6 1176991056273 08/31/1999 09/18/2000 MOVE 1 1 C1 92 QC $104&lt;BR /&gt;89 1.00 92&lt;BR /&gt;7 1176991866552 05/24/2000 1 1 A1 77 ON&lt;BR /&gt;89 92&lt;BR /&gt;8 1176992889500 11/28/2000 1 1 C1 68 AB $7&lt;BR /&gt;89 2.00 92&lt;BR /&gt;9 1177000067271 12/23/1999 0 1 B1 75 ON $13&lt;BR /&gt;89 4.00 92&lt;BR /&gt;10 1177010940613 12/09/1999 1 2 A1 42 NS $1&lt;BR /&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+---&lt;BR /&gt;89 1.00 92&lt;BR /&gt;NOTE: 10 records were read from the infile 'D:\Metro College class\Advanced SAS\Mini&lt;BR /&gt;Project\New_Wireless_Fixed.txt'.&lt;BR /&gt;The minimum record length was 92.&lt;BR /&gt;The maximum record length was 92.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.48 seconds&lt;BR /&gt;cpu time 0.04 seconds&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2023 23:57:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871475#M38604</guid>
      <dc:creator>V168</dc:creator>
      <dc:date>2023-04-23T23:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871476#M38605</link>
      <description>&lt;P&gt;Since you AGAIN pasted the text into the BODY of your message instead of using the features of this forum to allow you to share the un-altered text we have to guess what you are trying to show.&amp;nbsp; But since it looks like ALL of the lines are exact 92 bytes long I suspect that the fields are in in fixed columns.&amp;nbsp; So use the rulers that the LIST statement drew to help you write the INPUT statement using the right column numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First let me GUESS how to put your lines back together and then I can show you how to COUNT.&lt;/P&gt;
&lt;PRE&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9--
    1 1176913194483 06/20/1999                                               0 1 A1 58 BC  $128.00 92
    2 1176914599423 10/04/1999 10/15/1999 NEED                               1 1 A1 45 AB   $72.00 92
    3 1176951913656 07/01/2000                                               0 1 A1 57 BC  $593.00 92
    4 1176954000288 05/30/2000                                               1 2 A1 47 ON   $83.00 92
    5 1176969186303 12/13/2000                                               1 1 C1 82 BC          92
    6 1176991056273 08/31/1999 09/18/2000 MOVE                               1 1 C1 92 QC $1041.00 92
    7 1176991866552 05/24/2000                                               1 1 A1 77 ON          92
    8 1176992889500 11/28/2000                                               1 1 C1 68 AB   $72.00 92
    9 1177000067271 12/23/1999                                               0 1 B1 75 ON  $134.00 92
   10 1177010940613 12/09/1999                                               1 2 A1 42 NS   $11.00 92
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9--&lt;/PRE&gt;
&lt;P&gt;So you appear to have 6 fields at the end of the line, one at the start of the line and some unknown number in between.&amp;nbsp; Looks like the first two of those middle fields have DATE values in (the potentially confusing) MDY order.&amp;nbsp; Then there is at least one field that has strings like MOVE or NEED.&lt;/P&gt;
&lt;P&gt;You would need to look at more of the data to decide. &lt;STRONG&gt;Or better read the DESCRIPTION you got with the data that explains what the fields are and what columns they occupy.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input id $ 1-13&amp;nbsp;@15 date1 mmddyy10. @26 date2 mmddyy10. &amp;nbsp;36-40&amp;nbsp;$&amp;nbsp;motion&amp;nbsp;
      72&amp;nbsp;num1&amp;nbsp;74&amp;nbsp;num2&amp;nbsp;76-77&amp;nbsp;$&amp;nbsp;char1&amp;nbsp;79-80&amp;nbsp;num3&amp;nbsp;82-83&amp;nbsp;$&amp;nbsp;char2&amp;nbsp;@84&amp;nbsp;money&amp;nbsp;comma9.
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once you look at your real file instead of my attempt to clean up the lines that pasting into the body of a message destroyed you probably need to adjust the column numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notice that for the date fields and the money field you have to use FORMATTED mode input.&amp;nbsp; You cannot use a special informat with COLUMN MODE input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will need to attach a date type format to the date variables so that SAS will print the dates in a human readable style.&amp;nbsp; I recommend using either the DATE9. format or the YYMMDD10. format.&amp;nbsp; Displaying dates in either MDY or DMY order is confusing.&amp;nbsp; Which ever one you pick half of the audience will be confused by it.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 01:09:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871476#M38605</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-24T01:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871478#M38606</link>
      <description>&lt;P&gt;Thanks for your fast reply. Here I attached the split file, can you tell me the code to read the file.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 01:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871478#M38606</guid>
      <dc:creator>V168</dc:creator>
      <dc:date>2023-04-24T01:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871479#M38607</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;NOTE: The infile 'D:\Metro College class\Advanced SAS\Mini Project\New_Wireless_Fixed.txt' is:
      Filename=D:\Metro College class\Advanced SAS\Mini Project\New_Wireless_Fixed.txt,
      RECFM=V,LRECL=32767,File Size (bytes)=9611970,
      Last Modified=April 04, 2023 21:51:23,
      Create Time=April 04, 2023 21:51:21

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+---
1         1176913194483 06/20/1999                            0        1  A1       58    BC    $12
      89  8.00 92
2         1176914599423 10/04/1999 10/15/1999     NEED        1        1  A1       45    AB     $7
      89  2.00 92
3         1176951913656 07/01/2000                            0        1  A1       57    BC    $59
      89  3.00 92
4         1176954000288 05/30/2000                            1        2  A1       47    ON     $8
      89  3.00 92
5         1176969186303 12/13/2000                            1        1  C1       82    BC
      89       92
6         1176991056273 08/31/1999 09/18/2000     MOVE        1        1  C1       92    QC   $104
      89  1.00 92
7         1176991866552 05/24/2000                            1        1  A1       77    ON
      89       92
8         1176992889500 11/28/2000                            1        1  C1       68    AB     $7
      89  2.00 92
9         1177000067271 12/23/1999                            0        1  B1       75    ON    $13
      89  4.00 92
10        1177010940613 12/09/1999                            1        2  A1       42    NS     $1
RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+---
      89  1.00 92
NOTE: 10 records were read from the infile 'D:\Metro College class\Advanced SAS\Mini
      Project\New_Wireless_Fixed.txt'.
      The minimum record length was 92.
      The maximum record length was 92.
NOTE: DATA statement used (Total process time):
      real time           0.48 seconds
      cpu time            0.04 seconds


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Sorry maybe this time is the unulrtered text code&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 01:25:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871479#M38607</guid>
      <dc:creator>V168</dc:creator>
      <dc:date>2023-04-24T01:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871480#M38608</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;NOTE: The infile 'D:\Metro College class\Advanced SAS\Mini Project\New_Wireless_Fixed.txt' is:
      Filename=D:\Metro College class\Advanced SAS\Mini Project\New_Wireless_Fixed.txt,
      RECFM=V,LRECL=32767,File Size (bytes)=9611970,
      Last Modified=April 04, 2023 21:51:23,
      Create Time=April 04, 2023 21:51:21

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+---
1         1176913194483 06/20/1999                            0        1  A1       58    BC    $12
      89  8.00 92
2         1176914599423 10/04/1999 10/15/1999     NEED        1        1  A1       45    AB     $7
      89  2.00 92
3         1176951913656 07/01/2000                            0        1  A1       57    BC    $59
      89  3.00 92
4         1176954000288 05/30/2000                            1        2  A1       47    ON     $8
      89  3.00 92
5         1176969186303 12/13/2000                            1        1  C1       82    BC
      89       92
6         1176991056273 08/31/1999 09/18/2000     MOVE        1        1  C1       92    QC   $104
      89  1.00 92
7         1176991866552 05/24/2000                            1        1  A1       77    ON
      89       92
8         1176992889500 11/28/2000                            1        1  C1       68    AB     $7
      89  2.00 92
9         1177000067271 12/23/1999                            0        1  B1       75    ON    $13
      89  4.00 92
10        1177010940613 12/09/1999                            1        2  A1       42    NS     $1
RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+---
      89  1.00 92
NOTE: 10 records were read from the infile 'D:\Metro College class\Advanced SAS\Mini
      Project\New_Wireless_Fixed.txt'.
      The minimum record length was 92.
      The maximum record length was 92.
NOTE: DATA statement used (Total process time):
      real time           0.48 seconds
      cpu time            0.04 seconds


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;thanks for your fast reply and this the code I run and get some info for the file.&amp;nbsp; I also attached the split sorce data file&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 01:29:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871480#M38608</guid>
      <dc:creator>V168</dc:creator>
      <dc:date>2023-04-24T01:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871482#M38609</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/442039"&gt;@V168&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your fast reply. Here I attached the split file, can you tell me the code to read the file.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can do it yourself.&amp;nbsp; The file appears to have exactly the fields I identified before.&amp;nbsp; Only the actual column numbers are slightly different.&lt;/P&gt;
&lt;PRE&gt;----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9--
1176914599423 10/04/1999 10/15/1999     NEED        1        1  A1       45    AB     $72.00&lt;/PRE&gt;
&lt;P&gt;So the first field is in columns 1 to 13.&amp;nbsp; It looks like an identifier, so read it has CHARACTER even though it only contains digits.&lt;/P&gt;
&lt;P&gt;Then there are 2 date fields that are each 10 characters long at columns 15 and 26.&lt;/P&gt;
&lt;P&gt;Then that status field or whatever it is that is in columns 41 to 44.&lt;/P&gt;
&lt;P&gt;Then there are one character fields in column 53 and 62 and&amp;nbsp;two character fields in columns 65-66, 74-75 and 81-82.&amp;nbsp; Some of them only have digits so they could be read as numbers.&amp;nbsp; You will need to know what the strings mean to decide if it makes sense to treat them as a number or a string.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And finally the dollar amount at the end in columns 82 to 92.&amp;nbsp; So read it from column 82 using COMMA informat with a width of 11.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 02:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871482#M38609</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-24T02:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871487#M38610</link>
      <description>&lt;P&gt;Thank you so much, I will try to figure it out tomorrow&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 03:50:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871487#M38610</guid>
      <dc:creator>V168</dc:creator>
      <dc:date>2023-04-24T03:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871543#M38611</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data telecom;
infile 'c:\temp\xaa.txt' dlm=' ' termstr=crlf truncover;
input 
Acctno $ 1-14 
_Actdt $ 15-25
_Deactdt  $ 26-36
DeactReason $ 41-52
GoodCredit 53-61
RatePlan 62-64
DealerType $ 65-73
Age 74-79
Province $ 80-82
_Sales $ 83-93
;
Actdt=input(_Actdt,mmddyy12.);
Deactdt=input(_Deactdt,mmddyy12.);
Sales=input(_Sales,dollar32.);
format Actdt Deactdt mmddyy10. Sales dollar8.2;
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1682336562821.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83087iA69B9CA391DF063C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1682336562821.png" alt="Ksharp_0-1682336562821.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 11:42:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871543#M38611</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-04-24T11:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871547#M38613</link>
      <description>&lt;P&gt;Thank you so much for this code! it gives me the result, but the sequence of the column is not the original sequence, can you tell me why. Can you show me the code according to this sequence?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Data:

Acctno: account number.

Actdt: account activation date

Deactdt: account deactivation date

DeactReason: reason for deactivation.

GoodCredit: customer’s credit is good or not.

RatePlan: rate plan for the customer.

DealerType: dealer type.

Age: customer age.

Province: province.

Sales: the amount of sales to a customer

 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Apr 2023 11:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871547#M38613</guid>
      <dc:creator>V168</dc:creator>
      <dc:date>2023-04-24T11:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871552#M38614</link>
      <description>/*&lt;BR /&gt;OK. Just add one more data step after my code.&lt;BR /&gt;*/&lt;BR /&gt;data want;&lt;BR /&gt;retain&lt;BR /&gt;Acctno &lt;BR /&gt;Actdt &lt;BR /&gt;Deactdt  &lt;BR /&gt;DeactReason &lt;BR /&gt;GoodCredit &lt;BR /&gt;RatePlan &lt;BR /&gt;DealerType &lt;BR /&gt;Age &lt;BR /&gt;Province &lt;BR /&gt;Sales&lt;BR /&gt;;&lt;BR /&gt; set telecom;&lt;BR /&gt;run;</description>
      <pubDate>Mon, 24 Apr 2023 12:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871552#M38614</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-04-24T12:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871574#M38615</link>
      <description>&lt;P&gt;Thank you so much, it is woks!&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 13:07:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871574#M38615</guid>
      <dc:creator>V168</dc:creator>
      <dc:date>2023-04-24T13:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871577#M38616</link>
      <description>&lt;P&gt;There is no need to make the temporary character variables.&lt;/P&gt;
&lt;P&gt;Just read the fields that need special informats using FORMATTED MODE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input 
Acctno $ 1-14 
@15 Actdt mmddyy10.
@26 Deactdt  mmddyy10.
DeactReason $ 41-52
GoodCredit 53-61
RatePlan 62-64
DealerType $ 65-73
Age 74-79
Province $ 80-82
@83 Sales comma10.
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Apr 2023 13:25:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871577#M38616</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-24T13:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871714#M38617</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="V168_0-1682370023710.png" style="width: 577px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83111i5546315C4EDF03B9/image-dimensions/577x222?v=v2" width="577" height="222" role="button" title="V168_0-1682370023710.png" alt="V168_0-1682370023710.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I run this code,but didn't give me correct answer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 21:01:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871714#M38617</guid>
      <dc:creator>V168</dc:creator>
      <dc:date>2023-04-24T21:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871757#M38619</link>
      <description>&lt;P&gt;Looks good to me.&lt;/P&gt;
&lt;P&gt;You just forgot to attach formats to the date variables.&amp;nbsp; Add a format statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format actdt deactdt yymmdd10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You didn't attach a format to the Sales variable either, but that shouldn't matter as much as a human can still see what number it represents.&amp;nbsp; Printing thousands separators or $ prefix or fixed number of decimal places is just cosmetic.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 23:30:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871757#M38619</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-24T23:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871762#M38620</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;data telecom1;
infile 'D:\my file path' dlm=' ' termstr=crlf truncover;
input 
Acctno $ 1-14 
@15-25 Actdt mmddyy10.
@26-36 Deactdt  mmddyy10.
DeactReason $ 41-52
GoodCredit 53-61
RatePlan 62-64
DealerType $ 65-73
Age 74-79
Province $ 80-82
@83-93 Sales comma10.
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I run this code and get the result. Every thing fromated still give me wrong results. I don't know why. Have you run the code use the txt file I just attached.Just run the txt file, check the result.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 01:12:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871762#M38620</guid>
      <dc:creator>V168</dc:creator>
      <dc:date>2023-04-25T01:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871763#M38621</link>
      <description>&lt;P&gt;You need to read the date fields from column 15 and column 26.&amp;nbsp; So you need to use @15 and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/250606"&gt;@26&lt;/a&gt;.&amp;nbsp; &amp;nbsp;But you didn't do that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure if you are trying to tell SAS to move to column -10 and column -9 instead?&amp;nbsp; If so that cannot work as written since you would need to enclose the subtraction inside of parentheses. But of course even if you fixed the syntax you would still get an error you tried to move to a negative column number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fix the cursor movement command so it moves to the proper column before reading the next 10 characters as a date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;@15 Actdt mmddyy10.
@26 Deactdt  mmddyy10.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Fix the positioning for the SALES variable also.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 02:38:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871763#M38621</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-25T02:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to read txt file into SAS table why I always have problem</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871764#M38622</link>
      <description>&lt;P&gt;Perhaps you would find it less confusing to just use formatted mode for every variable?&lt;/P&gt;
&lt;P&gt;You probably will still need a cursor movement command as I don't think the MMDDYY informat would support a width of 11.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input 
  Acctno $14. 
  Actdt mmddyy10.
 +1
  Deactdt  mmddyy10.
  DeactReason $13.
  GoodCredit 9.
  RatePlan 3.
  DealerType $9.
  Age 5. 
  Province $3.
  Sales comma10.
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could also just read that extra space into a dummy variable that you do not keep in the dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input 
  Acctno $14. 
  Actdt mmddyy10.
  dummy $1.
  Deactdt  mmddyy10.
  DeactReason $13.
  GoodCredit 9.
  RatePlan 3.
  DealerType $9.
  Age 5. 
  Province $3.
  Sales comma10.
;
drop dummy ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Apr 2023 02:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-txt-file-into-SAS-table-why-I-always-have-problem/m-p/871764#M38622</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-25T02:47:59Z</dc:date>
    </item>
  </channel>
</rss>

