<?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 a Text file with a header record format and separate data record format in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Reading-a-Text-file-with-a-header-record-format-and-separate/m-p/351481#M10450</link>
    <description>&lt;P&gt;It has a changing Header such as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data goes from 1952 to Today, The header contains the date/time, and below it is data associated with that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#CAM00071109 1951 02 01 03 9999 14 ncar-ccd 506850 -1273758&lt;BR /&gt;21 -9999 102000B 19 -5B 743 -9999 -9999 -9999&lt;BR /&gt;10 -9999 100000 180B -18B 718 -9999 -9999 -9999&lt;BR /&gt;10 -9999 85000 1451B -98B 852 -9999 -9999 -9999&lt;BR /&gt;20 -9999 81400 -9999 -92B 924 -9999 -9999 -9999&lt;BR /&gt;20 -9999 75700 -9999 -95B 946 -9999 -9999 -9999&lt;BR /&gt;10 -9999 70000 2950B -122B 922 -9999 -9999 -9999&lt;BR /&gt;20 -9999 55500 -9999 -228B 882 -9999 -9999 -9999&lt;BR /&gt;20 -9999 52700 -9999 -245B 556 -9999 -9999 -9999&lt;BR /&gt;10 -9999 50000 5447B -272B 604 -9999 -9999 -9999&lt;BR /&gt;10 -9999 30000 8946B -500B-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 21700 -9999 -525A-9999 -9999 -9999 -9999&lt;BR /&gt;10 -9999 20000 11576B -518B-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 16400 -9999 -502B-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 13200 -9999 -525B-9999 -9999 -9999 -9999&lt;BR /&gt;#CAM00071109 1951 02 03 03 9999 7 ncar-ccd 506850 -1273758&lt;BR /&gt;21 -9999 99900B 19 35B 952 -9999 -9999 -9999&lt;BR /&gt;20 -9999 93500 -9999 22B 866 -9999 -9999 -9999&lt;BR /&gt;10 -9999 85000 1317B -28B 928 -9999 -9999 -9999&lt;BR /&gt;20 -9999 74500 -9999 -102B 785 -9999 -9999 -9999&lt;BR /&gt;10 -9999 30000 8769B -518B-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 26200 -9999 -538A-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 21700 -9999 -535A-9999 -9999 -9999 -9999&lt;BR /&gt;#CAM00071109 1951 02 04 03 9999 11 ncar-ccd 506850 -1273758&lt;BR /&gt;21 -9999 100900B 19 25B 951 -9999 -9999 -9999&lt;BR /&gt;10 -9999 100000 91B 25B 911 -9999 -9999 -9999&lt;BR /&gt;20 -9999 95000 -9999 18B 804 -9999 -9999 -9999&lt;BR /&gt;10 -9999 85000 1393B -42B 820 -9999 -9999 -9999&lt;BR /&gt;10 -9999 70000 2902B -122B 782 -9999 -9999 -9999&lt;BR /&gt;20 -9999 53000 -9999 -232B 615 -9999 -9999 -9999&lt;BR /&gt;10 -9999 50000 5404B -265B 606 -9999 -9999 -9999&lt;BR /&gt;10 -9999 30000 8882B -535B-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 24000 -9999 -608A-9999 -9999 -9999 -9999&lt;BR /&gt;10 -9999 20000 11445B -595B-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 16400 -9999 -585A-9999 -9999 -9999 -9999&lt;/P&gt;</description>
    <pubDate>Wed, 19 Apr 2017 22:50:41 GMT</pubDate>
    <dc:creator>jorentergesen</dc:creator>
    <dc:date>2017-04-19T22:50:41Z</dc:date>
    <item>
      <title>Reading a Text file with a header record format and separate data record format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Reading-a-Text-file-with-a-header-record-format-and-separate/m-p/351479#M10448</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having trouble reading a file into sas because it has two different data record formats, a header format and data format.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached the format of the data below, I am fairly new to sas and I am not sure how to make the data read with header(columns) the Date (Hour month day year) as the first column and then the variables of the record format. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not even quite sure how to start, I have uploaded files to sas before however, usually they are arranged in a neater format, I attacthed the data file if that helps.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help or even a starting point could help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Header:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Variable&amp;nbsp;&amp;nbsp; Columns&amp;nbsp; Type&lt;/P&gt;&lt;P&gt;---------------------------------&lt;/P&gt;&lt;P&gt;HEADREC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1-&amp;nbsp; 1&amp;nbsp; Character&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2- 12&amp;nbsp; Character&lt;/P&gt;&lt;P&gt;YEAR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14- 17&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;MONTH&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 19- 20&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;DAY&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22- 23&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;HOUR&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;25- 26&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;RELTIME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 28- 31&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;NUMLEV&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 33- 36&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;P_SRC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 38- 45&amp;nbsp; Character&lt;/P&gt;&lt;P&gt;NP_SRC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 47- 54&amp;nbsp; Character&lt;/P&gt;&lt;P&gt;LAT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 56- 62&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;LON&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 64- 71&amp;nbsp; Integer&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;Data Record Format: &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;LVLTYP1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1-&amp;nbsp; 1&amp;nbsp;&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;LVLTYP2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2-&amp;nbsp; 2&amp;nbsp;&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;ETIME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4-&amp;nbsp; 8&amp;nbsp;&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;PRESS&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10- 15&amp;nbsp;&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;PFLAG&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16- 16&amp;nbsp;&amp;nbsp; Character&lt;/P&gt;&lt;P&gt;GPH&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 17- 21&amp;nbsp;&amp;nbsp; Intege&lt;/P&gt;&lt;P&gt;rZFLAG&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22- 22&amp;nbsp;&amp;nbsp; Character&lt;/P&gt;&lt;P&gt;TEMP&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 23- 27&amp;nbsp;&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;TFLAG&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 28- 28&amp;nbsp;&amp;nbsp; Character&lt;/P&gt;&lt;P&gt;RH&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 29- 33&amp;nbsp;&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;DPDP&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 35- 39&amp;nbsp;&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;WDIR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 41- 45&amp;nbsp;&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;WSPD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 47- 51&amp;nbsp;&amp;nbsp; Integer&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;example of the data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#CAM00071109 1952 10 31 03 9999 14 ncar-ccd 506850 -1273758&lt;BR /&gt;21 -9999 101400B 19 72B 933 -9999 -9999 -9999&lt;BR /&gt;10 -9999 100000 134B 72B 933 -9999 -9999 -9999&lt;BR /&gt;10 -9999 85000 1439B -8B 863 -9999 -9999 -9999&lt;BR /&gt;10 -9999 70000 2978B -102B 748 -9999 -9999 -9999&lt;BR /&gt;20 -9999 57600 -9999 -208B 838 -9999 -9999 -9999&lt;BR /&gt;20 -9999 55000 -9999 -235B 614 -9999 -9999 -9999&lt;BR /&gt;10 -9999 50000 5480B -278B 596 -9999 -9999 -9999&lt;BR /&gt;10 -9999 40000 7041B -405B 671 -9999 -9999 -9999&lt;BR /&gt;10 -9999 30000 8955B -505B-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 27300 -9999 -530A-9999 -9999 -9999 -9999&lt;BR /&gt;10 -9999 20000 11595B -482B-9999 -9999 -9999 -9999&lt;BR /&gt;10 -9999 15000 13481B -502A-9999 -9999 -9999 -9999&lt;BR /&gt;10 -9999 10000 16142B -505A-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 6200 -9999 -530A-9999 -9999 -9999 -9999&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2017 22:39:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Reading-a-Text-file-with-a-header-record-format-and-separate/m-p/351479#M10448</guid>
      <dc:creator>jorentergesen</dc:creator>
      <dc:date>2017-04-19T22:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a Text file with a header record format and separate data record format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Reading-a-Text-file-with-a-header-record-format-and-separate/m-p/351480#M10449</link>
      <description>&lt;P&gt;If the file is formatted except header, write a data step to import the remaining records and ignore the first record entirely.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2017 22:42:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Reading-a-Text-file-with-a-header-record-format-and-separate/m-p/351480#M10449</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-19T22:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a Text file with a header record format and separate data record format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Reading-a-Text-file-with-a-header-record-format-and-separate/m-p/351481#M10450</link>
      <description>&lt;P&gt;It has a changing Header such as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data goes from 1952 to Today, The header contains the date/time, and below it is data associated with that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#CAM00071109 1951 02 01 03 9999 14 ncar-ccd 506850 -1273758&lt;BR /&gt;21 -9999 102000B 19 -5B 743 -9999 -9999 -9999&lt;BR /&gt;10 -9999 100000 180B -18B 718 -9999 -9999 -9999&lt;BR /&gt;10 -9999 85000 1451B -98B 852 -9999 -9999 -9999&lt;BR /&gt;20 -9999 81400 -9999 -92B 924 -9999 -9999 -9999&lt;BR /&gt;20 -9999 75700 -9999 -95B 946 -9999 -9999 -9999&lt;BR /&gt;10 -9999 70000 2950B -122B 922 -9999 -9999 -9999&lt;BR /&gt;20 -9999 55500 -9999 -228B 882 -9999 -9999 -9999&lt;BR /&gt;20 -9999 52700 -9999 -245B 556 -9999 -9999 -9999&lt;BR /&gt;10 -9999 50000 5447B -272B 604 -9999 -9999 -9999&lt;BR /&gt;10 -9999 30000 8946B -500B-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 21700 -9999 -525A-9999 -9999 -9999 -9999&lt;BR /&gt;10 -9999 20000 11576B -518B-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 16400 -9999 -502B-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 13200 -9999 -525B-9999 -9999 -9999 -9999&lt;BR /&gt;#CAM00071109 1951 02 03 03 9999 7 ncar-ccd 506850 -1273758&lt;BR /&gt;21 -9999 99900B 19 35B 952 -9999 -9999 -9999&lt;BR /&gt;20 -9999 93500 -9999 22B 866 -9999 -9999 -9999&lt;BR /&gt;10 -9999 85000 1317B -28B 928 -9999 -9999 -9999&lt;BR /&gt;20 -9999 74500 -9999 -102B 785 -9999 -9999 -9999&lt;BR /&gt;10 -9999 30000 8769B -518B-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 26200 -9999 -538A-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 21700 -9999 -535A-9999 -9999 -9999 -9999&lt;BR /&gt;#CAM00071109 1951 02 04 03 9999 11 ncar-ccd 506850 -1273758&lt;BR /&gt;21 -9999 100900B 19 25B 951 -9999 -9999 -9999&lt;BR /&gt;10 -9999 100000 91B 25B 911 -9999 -9999 -9999&lt;BR /&gt;20 -9999 95000 -9999 18B 804 -9999 -9999 -9999&lt;BR /&gt;10 -9999 85000 1393B -42B 820 -9999 -9999 -9999&lt;BR /&gt;10 -9999 70000 2902B -122B 782 -9999 -9999 -9999&lt;BR /&gt;20 -9999 53000 -9999 -232B 615 -9999 -9999 -9999&lt;BR /&gt;10 -9999 50000 5404B -265B 606 -9999 -9999 -9999&lt;BR /&gt;10 -9999 30000 8882B -535B-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 24000 -9999 -608A-9999 -9999 -9999 -9999&lt;BR /&gt;10 -9999 20000 11445B -595B-9999 -9999 -9999 -9999&lt;BR /&gt;20 -9999 16400 -9999 -585A-9999 -9999 -9999 -9999&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2017 22:50:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Reading-a-Text-file-with-a-header-record-format-and-separate/m-p/351481#M10450</guid>
      <dc:creator>jorentergesen</dc:creator>
      <dc:date>2017-04-19T22:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a Text file with a header record format and separate data record format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Reading-a-Text-file-with-a-header-record-format-and-separate/m-p/351482#M10451</link>
      <description>&lt;P&gt;The # symbol is only in front of your 'header' lines?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, create three input statements.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first reads the first character, if it's a # use the input from header record line.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second reads the record otherwise. You can use two trailing @@ to keep the pointer on the same line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This isn't a full solution but gives you the idea. Everything is read in as character here but you should customize that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover;
informat var1-var10 vart1-vart9 $20.;
input @1 char1 $1. @@;
if char1='#' then 
   input var1-var10 $;
else input varT1-varT9 $ ;
retain var1-var10;
cards;
#CAM00071109 1951 02 01 03 9999 14 ncar-ccd 506850 -1273758
21 -9999 102000B 19 -5B 743 -9999 -9999 -9999
10 -9999 100000 180B -18B 718 -9999 -9999 -9999
10 -9999 85000 1451B -98B 852 -9999 -9999 -9999
20 -9999 81400 -9999 -92B 924 -9999 -9999 -9999
20 -9999 75700 -9999 -95B 946 -9999 -9999 -9999
10 -9999 70000 2950B -122B 922 -9999 -9999 -9999
20 -9999 55500 -9999 -228B 882 -9999 -9999 -9999
20 -9999 52700 -9999 -245B 556 -9999 -9999 -9999
10 -9999 50000 5447B -272B 604 -9999 -9999 -9999
10 -9999 30000 8946B -500B-9999 -9999 -9999 -9999
20 -9999 21700 -9999 -525A-9999 -9999 -9999 -9999
10 -9999 20000 11576B -518B-9999 -9999 -9999 -9999
20 -9999 16400 -9999 -502B-9999 -9999 -9999 -9999
20 -9999 13200 -9999 -525B-9999 -9999 -9999 -9999
#CAM00071109 1951 02 03 03 9999 7 ncar-ccd 506850 -1273758
21 -9999 99900B 19 35B 952 -9999 -9999 -9999
20 -9999 93500 -9999 22B 866 -9999 -9999 -9999
10 -9999 85000 1317B -28B 928 -9999 -9999 -9999
20 -9999 74500 -9999 -102B 785 -9999 -9999 -9999
10 -9999 30000 8769B -518B-9999 -9999 -9999 -9999
20 -9999 26200 -9999 -538A-9999 -9999 -9999 -9999
20 -9999 21700 -9999 -535A-9999 -9999 -9999 -9999
;;;;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Apr 2017 23:11:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Reading-a-Text-file-with-a-header-record-format-and-separate/m-p/351482#M10451</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-19T23:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a Text file with a header record format and separate data record format</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Reading-a-Text-file-with-a-header-record-format-and-separate/m-p/351483#M10452</link>
      <description>&lt;P&gt;You may want to repost your example data in a code box opened by using the forum {i} menu icon.&lt;/P&gt;
&lt;P&gt;as posted when I copy the data to a text file your column 23 has the letter B for the first data record which is not valid for the TEMP variable as numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes the forum main window "helps" by reformatting text and may have removed sequential spaces or possibly tabs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This may be a starting example. I reformatted the data in the editor to better match the input descriptions. The numerics are defaulting to best. formats which look like integers.&lt;/P&gt;
&lt;PRE&gt;data read;
input @@;
if substr(_infile_,1,1)="#" then
input 
   HEADREC   $   1 
   ID        $   2- 12  
   YEAR         14- 17  
   MONTH        19- 20  
   DAY          22- 23  
   HOUR         25- 26  
   RELTIME      28- 31  
   NUMLEV       33- 36  
   P_SRC    $   38- 45  
   NP_SRC   $   47- 54  
   LAT          56- 62  
   LON          64- 71  
   ;
else input 
LVLTYP1         1   
LVLTYP2         2   
ETIME           4-  8   
PRESS          10- 15   
PFLAG     $    16- 16  
GPH            17   
rZFLAG    $    22- 22  
TEMP           23- 27   
TFLAG     $    28- 28  
RH             29- 33   
DPDP           35- 39   
WDIR           41- 45   
WSPD           47- 51   
; 
datetime=dhms(mdy(month,day,year),hour,0,0);
format datetime datetime16.;
datalines;
#CAM00071109 1952 10 31 03 9999 14  ncar-ccd 506850 -1273758
21 -9999 101400B 19      72B 933 -9999 -9999 -9999
10 -9999 100000 134B     72B 933 -9999 -9999 -9999
10 -9999 85000 1439B     -8B 863 -9999 -9999 -9999
10 -9999 70000 2978B   -102B 748 -9999 -9999 -9999
20 -9999 57600 -9999   -208B 838 -9999 -9999 -9999
20 -9999 55000 -9999   -235B 614 -9999 -9999 -9999
10 -9999 50000 5480B   -278B 596 -9999 -9999 -9999
10 -9999 40000 7041B   -405B 671 -9999 -9999 -9999
10 -9999 30000 8955B   -505B-9999 -9999 -9999 -9999
20 -9999 27300 -9999   -530A-9999 -9999 -9999 -9999
10 -9999 20000 11595B  -482B-9999 -9999 -9999 -9999
10 -9999 15000 13481B  -502A-9999 -9999 -9999 -9999
10 -9999 10000 16142B  -505A-9999 -9999 -9999 -9999
20 -9999 6200  -9999   -530A-9999 -9999 -9999 -9999
;
run;
&lt;/PRE&gt;
&lt;P&gt;If you want the values from the header record to be one the data records add a RETAIN statement listing the header variables of interest. I also created a datetime variable as putting date/time information together is often better than the separate fields. Note though that if any of the incoming values are not valid dates, ie month=2 and day=31, then the datetime is going to through an error about invalid date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2017 23:16:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Reading-a-Text-file-with-a-header-record-format-and-separate/m-p/351483#M10452</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-19T23:16:02Z</dc:date>
    </item>
  </channel>
</rss>

