<?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 in a non-delimited file into SAS in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-in-a-non-delimited-file-into-SAS/m-p/793994#M40202</link>
    <description>&lt;P&gt;Without seeing an example for the data, I can give you exactly zero help. I can have no clue if you have some kind of column separator, or fixed width columns, or any other thing that can help in locating column boundaries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your request is like requesting a diagnosis from a doctor who is made deliberately deaf and blind and is not allowed to touch you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post the example as requested, and overwrite sensitive values with X's or 0's (one character for one character, and leave everything else - special characters! - untouched).&lt;/P&gt;</description>
    <pubDate>Wed, 02 Feb 2022 12:11:28 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-02-02T12:11:28Z</dc:date>
    <item>
      <title>Reading in a non-delimited file into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-in-a-non-delimited-file-into-SAS/m-p/793989#M40199</link>
      <description>&lt;P&gt;Good Morning,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a file which is not delimited so it's difficult to judge when one column ends and other begins. However, I have metadata around the maximum size the columns will be and whether they should be numeric or alphanumeric. Below is a snippet of the information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone recommend an efficient way to read these and create a SAS dataset, please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&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02 Feb 2022 11:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-in-a-non-delimited-file-into-SAS/m-p/793989#M40199</guid>
      <dc:creator>Sean_OConnor</dc:creator>
      <dc:date>2022-02-02T11:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in a non-delimited file into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-in-a-non-delimited-file-into-SAS/m-p/793991#M40200</link>
      <description>&lt;P&gt;Please open your file with a text editor(!) and copy/paste a few lines into a window opened with this button:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54552i914D97BE1B0F21E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 12:02:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-in-a-non-delimited-file-into-SAS/m-p/793991#M40200</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-02T12:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in a non-delimited file into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-in-a-non-delimited-file-into-SAS/m-p/793992#M40201</link>
      <description>Hi Kurt. Unfortunately I can't do this as it isn't publicly available data. I'm wondering if an infile, informat, input statement work?</description>
      <pubDate>Wed, 02 Feb 2022 12:06:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-in-a-non-delimited-file-into-SAS/m-p/793992#M40201</guid>
      <dc:creator>Sean_OConnor</dc:creator>
      <dc:date>2022-02-02T12:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in a non-delimited file into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-in-a-non-delimited-file-into-SAS/m-p/793994#M40202</link>
      <description>&lt;P&gt;Without seeing an example for the data, I can give you exactly zero help. I can have no clue if you have some kind of column separator, or fixed width columns, or any other thing that can help in locating column boundaries.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your request is like requesting a diagnosis from a doctor who is made deliberately deaf and blind and is not allowed to touch you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post the example as requested, and overwrite sensitive values with X's or 0's (one character for one character, and leave everything else - special characters! - untouched).&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 12:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-in-a-non-delimited-file-into-SAS/m-p/793994#M40202</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-02T12:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in a non-delimited file into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-in-a-non-delimited-file-into-SAS/m-p/794006#M40203</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/116786"&gt;@Sean_OConnor&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;This should not be difficult. Something which one does come across.I used the approach as shown in the example below.&lt;/P&gt;
&lt;P&gt;Hope this should solve your issue.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
length line $ 
256;
input line $;
datalines;
AB1234567123456789ABCDEFGH
;;
run;
data test2;
set test;
var1=substr(line,1,9);
var2=substr(line,10,9);
var3=substr(line,19,3);
var4=substr(line,22);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Feb 2022 13:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-in-a-non-delimited-file-into-SAS/m-p/794006#M40203</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-02-02T13:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in a non-delimited file into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-in-a-non-delimited-file-into-SAS/m-p/794042#M40204</link>
      <description>&lt;P&gt;If your source is text and there actually is no delimiter then likely the data is fixed column. This documentation is the basic approach for that type of data:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/lestmtsref/n13ejk9swz5vrbn0z34iazfrp0wp.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/lestmtsref/n13ejk9swz5vrbn0z34iazfrp0wp.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Specify the columns to read (hint: Var1 is columns 1 to 9, Var2 is 10 to 22 &lt;STRONG&gt;if&lt;/STRONG&gt; your description is accurate and the data is fixed column).&lt;/P&gt;
&lt;P&gt;Caution: 13 digits for numbers sounds likely to be odd. If these are things like account numbers or identifiers that are not to be used in numeric calculations likely they should be character. If they have leading zeroes that you want to see then they &lt;STRONG&gt;really &lt;/STRONG&gt;should be character. Unfortunately many folks don't make a difference in their documentation and will say anything that contains only digits is "numeric".&lt;/P&gt;
&lt;P&gt;Note: if you have date, time or date time values you will want to be very specific about the informat used to read them to get actual SAS date, time or datetime values and assign an appropriate format for human legibility.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 15:29:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-in-a-non-delimited-file-into-SAS/m-p/794042#M40204</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-02T15:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in a non-delimited file into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-in-a-non-delimited-file-into-SAS/m-p/794068#M40205</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/116786"&gt;@Sean_OConnor&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assuming that your file has fixed field widths, here's a simple code example using &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p0f9yk6pd4znukn1rlw6hzkg1url.htm" target="_blank" rel="noopener"&gt;formatted input&lt;/A&gt;&amp;nbsp;(which I prefer to&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n13ejk9swz5vrbn0z34iazfrp0wp.htm" target="_blank" rel="noopener"&gt;column input&lt;/A&gt;) and five variables:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create test data for demonstration */

filename ft15f001 temp;
parmcards;
B.1.1.52911,222,333.00-12987SOMETEXT
B.1.351 S49,999.95    17 101shorter
;

/* Read test data */

data want;
infile ft15f001 truncover;
input var1 $9.
      var2 comma13.
      var3 3.
      var4 3.
      var5 $upcase8.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm#p1w53eurb5rzvsn1sf102hn7ticw" target="_blank" rel="noopener"&gt;TRUNCOVER&lt;/A&gt; option helps to avoid problems if the record length may vary (as in the example). The length specifications (9, 13, 3, ...) in each informat are important as they determine the columns to be read for each variable (i.e., columns 1 - 9 for VAR1, 10 - 22 for VAR2, ...). For the character variables they also define the lengths (if not defined otherwise, e.g., by a LENGTH statement). Use character informats for character variables and numeric informats for numeric variables. (Note that the SAS variable type can differ from the raw data type, e.g., the numeric DATE9. informat can read an "alphanumeric" field with data like &lt;FONT face="courier new,courier"&gt;01Jan2022&lt;/FONT&gt;&amp;nbsp;and vice versa, as mentioned by &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884" target="_blank" rel="noopener"&gt;ballardw&lt;/A&gt;.) Of course, your &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm" target="_blank" rel="noopener"&gt;INFILE statement&lt;/A&gt; will refer to a different file name or to a physical path.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 17:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Reading-in-a-non-delimited-file-into-SAS/m-p/794068#M40205</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-02-02T17:06:08Z</dc:date>
    </item>
  </channel>
</rss>

