<?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: Exporting to SAS unparsed file specific characters only. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828580#M327301</link>
    <description>&lt;P&gt;I doubt the HEADER text is in a random location.&amp;nbsp; You just haven't figured out the pattern.&lt;/P&gt;
&lt;P&gt;If the file starts with variable length information there are two main ways that is stored.&lt;/P&gt;
&lt;P&gt;One is to have some type of termination character, normally binary zero, '00'x in SAS syntax.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename example temp;
data _null_;
  file example ;
  string='XXXXXXXXXXXX';
  do i=1 to 8 ;
    put string $varying10. i '00'x ' HEADER 9 10 20' ;
  end;
run;

data _null_;
 infile example;
 input;
 list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The other is to first specify the length.&amp;nbsp; So normally that would be stored as a binary integer value.&amp;nbsp; Could be 1, 2 or 4 bytes long perhaps.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename example temp;
data _null_;
  file example ;
  string='XXXXXXXXXXXX';
  do i=1 to 8 ;
    put i pib2. string $varying10. i ' HEADER 9 10 20' ;
  end;
run;

data _null_;
 infile example;
 input;
 list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 13 Aug 2022 20:13:00 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-08-13T20:13:00Z</dc:date>
    <item>
      <title>Exporting to SAS unparsed file specific characters only.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828568#M327289</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I would appreciate any advice and help on how to tackle text processing task and would like to find out the following:&lt;/P&gt;
&lt;P&gt;1. Is there a way in SAS to scan a file with non standard extension (file contains data that is made to be processed by an application) and import only portion that contains standard - human readable alpha numeric characters and drop all encoded symbols that should be used/decoded by the application.&lt;/P&gt;
&lt;P&gt;2. is there a way to scan a file for a specific identifier "HEADER" and grab n charterers after it and put in a separate row keep everything in one column. --this would be the best.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As of now I have used the following:&lt;/P&gt;
&lt;P&gt;1. Imported file with "all" extensions and used suggested columns by SAS (215 columns, 65370 rows; the largest lengh 32767) and delimiter used as coma. Columns have different length and data is getting lost--have tried different delimiters, and number of columns.&lt;/P&gt;
&lt;P&gt;2. cleaned all from gibberish symbols and left only variables that contain "HEADER"&lt;/P&gt;
&lt;P&gt;data data_an; &lt;BR /&gt;set data_in; &lt;BR /&gt;array chars {*} _character_; &lt;BR /&gt;do _n_ = 1 to dim(chars); &lt;BR /&gt;chars{_n_} = compbl(prxchange("s/[^0-9 ABCDEFGHIJKLMNOPQRSTUVWXYZ-]//",-1,chars{_n_})); &lt;BR /&gt;if index(chars{_n_},"HEADER")=0 then chars{_n_}="";&lt;BR /&gt;end; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;3. Next dropped all columns that do not have any record; Code found on this site--Thank you; The output table has&amp;nbsp; single value with "HEADER" in each row;however,&amp;nbsp; columns are random for example output matrix:&lt;/P&gt;
&lt;P&gt;1 0 0 0&lt;/P&gt;
&lt;P&gt;0 0 1 0&lt;/P&gt;
&lt;P&gt;1 0 0 0&lt;/P&gt;
&lt;P&gt;0 1 0 0&lt;/P&gt;
&lt;P&gt;1- contains "HEADER" matrix dimensions 65k rows and&amp;nbsp; 21 columns&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ods select none;&lt;BR /&gt;ods output nlevels=temp;&lt;BR /&gt;proc freq data=data_an nlevels;&lt;BR /&gt;tables _all_;&lt;BR /&gt;run;&lt;BR /&gt;ods select all;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select tablevar into : drop separated by ' '&lt;BR /&gt;from temp &lt;BR /&gt;where NNonMissLevels=0;&lt;BR /&gt;quit;&lt;BR /&gt;data data_an1;&lt;BR /&gt;set data_an(drop=&amp;amp;drop);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. Create a column vector and delete all empty. F: --columns with text, n row number.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc transpose data=data_an1 out=data_an2;&lt;BR /&gt;by n;&lt;BR /&gt;var F:;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data text;&lt;BR /&gt;set data_an2;&lt;BR /&gt;if COL1='' then delete;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;5. Extract portion after the "HEADER" and check if variable contains more than one instance of header--may need to create a loop to capture situation when more than "HEADER" instance in the string. Is there a better way?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data text_out(drop=COL1 _NAME_ n);&lt;BR /&gt;set text;&lt;/P&gt;
&lt;P&gt;text=substr(COL1,index(COL1, 'HEADER'),60);&lt;/P&gt;
&lt;P&gt;*extract the first ID and Date that are separated by space;&lt;BR /&gt;ID=scan(text, 2, ' ');&lt;BR /&gt;DATE=scan(text, 3, ' ');&lt;/P&gt;
&lt;P&gt;*check if there is another index presented;&lt;/P&gt;
&lt;P&gt;index1=index(COL1, 'HEADER');&lt;BR /&gt;text1=index(substr(COL1,index1+8),'HEADER');&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code is very slow single run takes about 20 min; I am looking to process 1000-3000 files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 13:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828568#M327289</guid>
      <dc:creator>val_nikolajevs</dc:creator>
      <dc:date>2022-08-13T13:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to SAS unparsed file specific characters only.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828569#M327290</link>
      <description>&lt;P&gt;You can read any file with SAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you know what the file structure actually is?&amp;nbsp; If not first step is to LOOK at the file.&lt;/P&gt;
&lt;P&gt;For example this code will display the first 1,000 bytes of a file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile "myfile.abc" lrecl=100 recfm=f obs=10;
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to search for specific text as a trigger, such as the string 'HEADER' you mentioned the the INPUT statement can handle that.&amp;nbsp; Say you want the first 20 bytes that appear after every occurrence of HEADER in the file.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data header ;
  infile 'myfile.abc' recfm=n ;
  input @ 'HEADER' string $char20. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And once you figure out how to read one file of this type there are two ways to read multiples.&amp;nbsp; One is to make a list of the files and run the same steps over and over generating a separate dataset from each file.&amp;nbsp; The other is to read ALL of the files at&amp;nbsp; once into a single dataset.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 15:47:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828569#M327290</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-08-13T15:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to SAS unparsed file specific characters only.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828570#M327291</link>
      <description>&lt;P&gt;Note that your first step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;As of now I have used the following:&lt;/P&gt;
&lt;P&gt;1. Imported file with "all" extensions and used suggested columns by SAS (215 columns, 65370 rows; the largest lengh 32767) and delimiter used as coma. Columns have different length and data is getting lost--have tried different delimiters, and number of columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;only makes sense if you expected the files to be delimited text files.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it sounds like you expect the files to be binary files with some areas of plain text.&amp;nbsp; So trying to use any "import" procedure is not going to have any value at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 16:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828570#M327291</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-08-13T16:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to SAS unparsed file specific characters only.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828571#M327292</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;Running the first step got the following output form which I only need "HEADER 000091503847 080822085601":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 &lt;BR /&gt;1 HEADER 000091503847 080822085601 23742.22 &lt;BR /&gt;2 02 14809.67 03 8932.552 04 &lt;BR /&gt;3 A3 MVR FCS 20HEADTB000091503847 010322293000 &lt;BR /&gt;4 0000000000 3F0D4F 080820220855210808202208545703702020304031320220&lt;BR /&gt;5 200110720210200&lt;/P&gt;
&lt;P&gt;6 CHAR HEADTL000091503847 ....?...-.PSEM.. ..............&lt;BR /&gt;ZONE 2222222222224444543333333333332222222200003000205544002222222222222222222222222222222200000000000000&lt;BR /&gt;NUMR 00000000000085144C000091503847000000008080F780D0035D000000000000000000000000000000000000000000000000&lt;/P&gt;
&lt;P&gt;7 CHAR .................................................................. &lt;BR /&gt;ZONE 0000000000000000000000000000000000000000000000000000000000000000002222222222222222222222222222222222&lt;BR /&gt;NUMR 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000&lt;BR /&gt;2 The SAS System 09:23 Saturday, August 13, 2022&lt;/P&gt;
&lt;P&gt;RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0&lt;/P&gt;
&lt;P&gt;8 CHAR RGDATA1.202208080856A3 HDRT&lt;BR /&gt;ZONE 2222222222222222222222222222222222222222222222222222222222222222222254445431333333333333432222224455&lt;BR /&gt;NUMR 0000000000000000000000000000000000000000000000000000000000000000000027414112202208080856130000008424&lt;/P&gt;
&lt;P&gt;9 CHAR ABÿÿ&amp;amp;....&amp;amp;.......001000004002EE A3R A3 030414002STDTAB..O....O.........šEE ............ÿ.ðß.&lt;BR /&gt;ZONE 44FF2000020000000333333333333442243522222432223333333335545440040000400000001094422001100000000FAFD0&lt;BR /&gt;NUMR 12FF60100600000000010000040025500132000001300003041400234441200F0100F00000002AA5500203810DD35D6FD0F3&lt;/P&gt;
&lt;P&gt;10 CHAR ?üðÁ.ÿÿ.&amp;gt;ï¯&amp;nbsp;.…ÿÿ.0.ÿ÷ø_.þÿ..Ûà¨à..4h`€.üó.$¥.&amp;nbsp;...g..‚õàSTDTAB.. .... .......EE A3R .... &lt;BR /&gt;ZONE 3FFC1FF03EAA08FF038FFF51FF11DEAE0036680FF02A0A0816008FE554544002000020000000442243522222000022222222&lt;BR /&gt;NUMR FC01FFF3EFF015FFF0FF78F0EFA6B080834800AC304500119700250344412100010000000000550013200000304200000000&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Running the second portion gives me an error:&lt;/P&gt;
&lt;P&gt;ERROR: The '@"STRING"' INPUT/PUT statement option is inconsistent with binary mode I/O. The execution of the DATA STEP is being &lt;BR /&gt;terminated. Ho to fix that o tried to convert header to binary no luck sas hangs up and loses connection.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you are correct using import does not produce good results eher have tried UTF-16 seems to be looks cleaner and loads much faster but not sure how to get data to normal format back.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;filename test "\ID.HHF"&amp;nbsp;encoding='utf-16' ;&lt;BR /&gt;proc import datafile=test out=work.dataset dbms=dlm replace;&lt;BR /&gt;delimiter='090a'x;&lt;BR /&gt;getnames=no; &lt;BR /&gt;datarow=1;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 16:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828571#M327292</guid>
      <dc:creator>val_nikolajevs</dc:creator>
      <dc:date>2022-08-13T16:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to SAS unparsed file specific characters only.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828576#M327297</link>
      <description>&lt;P&gt;Really stuck on this one:&lt;/P&gt;
&lt;P&gt;ERROR: The '@"STRING"' INPUT/PUT statement option is inconsistent with binary mode I/O. The execution of the DATA STEP is being &lt;BR /&gt;terminated.&lt;/P&gt;
&lt;P&gt;it is not finding 'HEADER' and just puts everything in to a single column with specified $char20. length.&lt;/P&gt;
&lt;P&gt;Have read the following on INPUT and it seems should work with this expression; but it does not.&lt;/P&gt;
&lt;P&gt;input @'HEADER' string&amp;nbsp; $char20.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000144370.htm#a000144376" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000144370.htm#a000144376&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;What it could be?&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 18:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828576#M327297</guid>
      <dc:creator>val_nikolajevs</dc:creator>
      <dc:date>2022-08-13T18:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to SAS unparsed file specific characters only.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828577#M327298</link>
      <description>&lt;P&gt;Pasting the log notes into the forum as if it was your paragraphs of text has destroyed the layout.&amp;nbsp; Make sure to use the Insert Code or Insert SAS code button to get a pop-up for pasting/editing text and programs.&lt;/P&gt;
&lt;P&gt;Here is my best reconstruction of what you posted. (although the spacing in the first 500 bytes is probably way off)&lt;/P&gt;
&lt;PRE&gt;RULE:   ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
 1      HEADER 000091503847 080822085601 23742.22
 2      02 14809.67 03 8932.552 04
 3      A3 MVR FCS 20HEADTB000091503847 010322293000
 4      0000000000 3F0D4F 080820220855210808202208545703702020304031320220
 5      200110720210200
 6 CHAR             HEADTL000091503847        ....?...-.PSEM..                                ..............
   ZONE 2222222222224444543333333333332222222200003000205544002222222222222222222222222222222200000000000000
   NUMR 00000000000085144C000091503847000000008080F780D0035D000000000000000000000000000000000000000000000000
 7 CHAR ..................................................................
   ZONE 0000000000000000000000000000000000000000000000000000000000000000002222222222222222222222222222222222
   NUMR 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
 8 CHAR                                                                     RGDATA1.202208080856A3      HDRT
   ZONE 2222222222222222222222222222222222222222222222222222222222222222222254445431333333333333432222224455
   NUMR 0000000000000000000000000000000000000000000000000000000000000000000027414112202208080856130000008424
 9 CHAR ABÿÿ&amp;amp;....&amp;amp;.......001000004002EE  A3R     A3   030414002STDTAB..O....O.........šEE  ............ÿ.ðß.
   ZONE 44FF2000020000000333333333333442243522222432223333333335545440040000400000001094422001100000000FAFD0
   NUMR 12FF60100600000000010000040025500132000001300003041400234441200F0100F00000002AA5500203810DD35D6FD0F3
10 CHAR ?üðÁ.ÿÿ.&amp;gt;ï¯ .…ÿÿ.0.ÿ÷ø_.þÿ..Ûà¨à..4h`€.üó.$¥. ...g..‚õàSTDTAB.. .... .......EE  A3R     ....
   ZONE 3FFC1FF03EAA08FF038FFF51FF11DEAE0036680FF02A0A0816008FE554544002000020000000442243522222000022222222
   NUMR FC01FFF3EFF015FFF0FF78F0EFA6B080834800AC304500119700250344412100010000000000550013200000304200000000&lt;/PRE&gt;
&lt;P&gt;If the file always just has HEADER as the first 6 bytes and you just want to read the next 20 bytes then what you asked is trivial.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile 'myfile.abc' recfm=n ;
  input header $6.  otherstuff $char20. ;
  output;
  stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To see the actual pattern try running the LIST statement on a few of the files and see if you see the pattern to where things are placed in the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 19:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828577#M327298</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-08-13T19:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to SAS unparsed file specific characters only.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828578#M327299</link>
      <description>&lt;P&gt;Sorry. You can only use the&amp;nbsp;@ 'string' feature of INPUT when reading from files with records.&lt;/P&gt;
&lt;P&gt;Either text that is broken into lines by end of line characters, the default.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or by reading fixed length records using LRECL= and RECFM=F.&lt;/P&gt;
&lt;P&gt;Your example file does not appear to have end of line markers (at least not in the first 1000 bytes)&lt;/P&gt;
&lt;P&gt;Also not clear if there is a fixed length record length either.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you posted did not look like UTF-16.&amp;nbsp; That would have extra null bytes before every actual character.&amp;nbsp; I suspect it is just a binary format file where some of the fields have text and some of the fields are actually binary values.&amp;nbsp; Perhaps binary integer values, but perhaps other binary values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 19:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828578#M327299</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-08-13T19:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to SAS unparsed file specific characters only.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828579#M327300</link>
      <description>&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; that is the problem it is not in the first position it is random; I have found a work around:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data header ;&lt;BR /&gt;infile "\ID.HHF" recfm=n obs=1000 ;&lt;/P&gt;
&lt;P&gt;input string : $char32767.;&lt;BR /&gt;text=compbl(prxchange("s/[^0-9 ABCDEFGHIJKLMNOPQRSTUVWXYZ-]//",-1,string)); &lt;BR /&gt;if text='HEADER' then do;&lt;BR /&gt;count=1;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;else if count&amp;lt;3 then do;&lt;BR /&gt;output;&lt;BR /&gt;count=count+1;&lt;BR /&gt;end;&lt;BR /&gt;else delete;&lt;BR /&gt;retain count;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Puts everything in single column vector (was possible because there a spaces separating HEADER and values and infile with out delimiter treats each space as a delimiter), removes all weird characters, finds HEADER and grabs next two rows that exactly what I need it now just transposing to normal row/columns format.&lt;/P&gt;
&lt;P&gt;THANK YOU for the infile/input direction!&lt;/P&gt;</description>
      <pubDate>Sat, 13 Aug 2022 19:41:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828579#M327300</guid>
      <dc:creator>val_nikolajevs</dc:creator>
      <dc:date>2022-08-13T19:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to SAS unparsed file specific characters only.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828580#M327301</link>
      <description>&lt;P&gt;I doubt the HEADER text is in a random location.&amp;nbsp; You just haven't figured out the pattern.&lt;/P&gt;
&lt;P&gt;If the file starts with variable length information there are two main ways that is stored.&lt;/P&gt;
&lt;P&gt;One is to have some type of termination character, normally binary zero, '00'x in SAS syntax.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename example temp;
data _null_;
  file example ;
  string='XXXXXXXXXXXX';
  do i=1 to 8 ;
    put string $varying10. i '00'x ' HEADER 9 10 20' ;
  end;
run;

data _null_;
 infile example;
 input;
 list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The other is to first specify the length.&amp;nbsp; So normally that would be stored as a binary integer value.&amp;nbsp; Could be 1, 2 or 4 bytes long perhaps.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename example temp;
data _null_;
  file example ;
  string='XXXXXXXXXXXX';
  do i=1 to 8 ;
    put i pib2. string $varying10. i ' HEADER 9 10 20' ;
  end;
run;

data _null_;
 infile example;
 input;
 list;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Aug 2022 20:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828580#M327301</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-08-13T20:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to SAS unparsed file specific characters only.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828724#M327368</link>
      <description>&lt;P&gt;Tom --Thank you for the reply.&lt;/P&gt;
&lt;P&gt;Disclosure, I do not have expedience with processing files as binary.&lt;/P&gt;
&lt;P&gt;I could not figure out the structure and make it work as you suggested. However, with some modifications of the code with prxchange, I was able to get data that I was looking to extract.&lt;/P&gt;
&lt;P&gt;I can see start stop for each&amp;nbsp; ID, when i see file in note pad it ends/starts with "....ÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿþÿHEADER..." . However, this sequence is not located at a fixed col it is random for each ID--as far I can tell.&lt;/P&gt;
&lt;P&gt;I would marked this as a closed; Takes about 30-50 sec to process a file -- which is acceptable, for this one time task.&lt;/P&gt;
&lt;P&gt;Once again thank you.&lt;/P&gt;
&lt;P&gt;Val&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 16:51:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828724#M327368</guid>
      <dc:creator>val_nikolajevs</dc:creator>
      <dc:date>2022-08-15T16:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting to SAS unparsed file specific characters only.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828735#M327373</link>
      <description>&lt;P&gt;Glad you got it working.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The LIST statement is your friend.&amp;nbsp; It let's you see the file contents and exactly what the bytes contain.&amp;nbsp; Any place where there are characters that are not normal characters the LIST command will display the whole line with the two digit hex code for the characters underneath them.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 18:27:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-to-SAS-unparsed-file-specific-characters-only/m-p/828735#M327373</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-08-15T18:27:45Z</dc:date>
    </item>
  </channel>
</rss>

