<?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: Parsing column names and corresponding rows from a messy text file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775499#M246515</link>
    <description>&lt;P&gt;Super User Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the response.&amp;nbsp; Here are the answers to your questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What is the meaning of the rows&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;For example, "6=FIX3.3" should read 6 as the column name and FIX3.3 as the row value.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Does the order on the line have any meaning&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;Order does not have any meaning.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What is the meaning of the numbers in front of the equal signs&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;The meaning of the numbers in front of the equal signs is merely the column name.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;What is the meaning of the text after the equal signs&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;The meaning of the text after the equal signs is the row value.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Do you want to reduce it back to the same number of rows&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;Yes, I would like to reduce it back to the same number of rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
    <pubDate>Wed, 20 Oct 2021 19:33:08 GMT</pubDate>
    <dc:creator>emssas</dc:creator>
    <dc:date>2021-10-20T19:33:08Z</dc:date>
    <item>
      <title>Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775285#M246432</link>
      <description>&lt;P&gt;I am a relatively new SAS programmer who is using SAS Enterprise Guide to import a messy text file that contains unstructured data.&amp;nbsp; I need help creating a data step that splits the data into appropriate columns and corresponding rows of data.&amp;nbsp; The actual file contains many more columns and over 1 million rows of data.&amp;nbsp; The good news is that I only need 15 columns of data.&amp;nbsp; The bad news is that some of the columns and rows are listed in another column's row values.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Raw Data file:&lt;/P&gt;&lt;PRE&gt;6=FIX.3.3; 5=1057; 25=8; 24=798; 55=RBCC_MID_PROD; 56=TOP_MUD_PROD; 33=N; 52=20210915-12:38:16.753; 
24=802; 5=1079; 25=8; 6=FIX.3.3; 55=RBCC_MID_PROD; 56=TOP_MUD_PROD; 33=N; 52=20210915-12:39:50.053; 115=XPAS; 
6=FIX.3.3; 5=1095; 25=8; 24=803; 55=RBCC_MID_PROD; 56=TOP_MID_PROD; 33=N; 52=20210915-12:39:50.139; 115=XNAS; 1133=G; 
24=837; 5=1192; 25=8; 95=stiev; 6=FIX.3.3; 55=RBCC_MID_PROD; 56=TOP_MUD_PROD; 33=N; 52=20210915-12:56:23.691; 115=XNYS; 1133=G; 8101=CARE; 
6=FIX.3.3; 5=1189; 25=8; 95=mwonka; 24=844; 55=RBCC_TOP_PROD; 56=TOP_MUD_PROD; 33=N; 52=20210915-12:59:36.825; 115=XPAS; 1133=G; 8101=CARE; 8115=AOZ; &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS Code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc import
    file="...\SAS_Sample.log"
    out=messy_data
    dbms=tab
    replace;
    delimiter=";";
run;

data clean_data;&lt;BR /&gt;    set messy_data;&lt;BR /&gt;    &lt;FONT color="#FF0000"&gt;**Need help here**

&lt;/FONT&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here is the SAS output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="emssas_1-1634681884685.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64864i9F83FBCEDD063308/image-size/large?v=v2&amp;amp;px=999" role="button" title="emssas_1-1634681884685.png" alt="emssas_1-1634681884685.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I need the SAS data to look like:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="emssas_2-1634681931230.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64865i71E888BC73F5A188/image-size/large?v=v2&amp;amp;px=999" role="button" title="emssas_2-1634681931230.png" alt="emssas_2-1634681931230.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 17:27:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775285#M246432</guid>
      <dc:creator>emssas</dc:creator>
      <dc:date>2021-10-20T17:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775304#M246443</link>
      <description>&lt;P&gt;Proc Import as you have discovered will not read this.&lt;/P&gt;
&lt;P&gt;Data step code will be needed. Unfortunately your values have things that are not valid variable names, i.e. 6=. 6 is not a valid name or else we could use an uncommon option called Named input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create variables that you would have to name and reference &lt;STRONG&gt;everwhere&lt;/STRONG&gt; as "6"n but I strongly suggest not doing so. One mistyped quote and you can generate a lot of errors; a missing n or a space between the quote and the n and another set of errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have any documentation for this file? Such as lengths of variables, just how many of those 6= key values there are? Is any of those keys going to present on every single row?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 00:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775304#M246443</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-20T00:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775307#M246445</link>
      <description>&lt;P&gt;Not hard to read. Making sense of it would require a better description of what it means.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tall;
  infile csv dsd dlm=';' truncover;
  length row col number 8 string $40 ;
  row+1;
  do col=1 by 1 ;
    input string @;
    if string=' ' then leave;
    number=input(scan(string,1,'='),32.);
    string=scan(string,2,'=');
    output;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Partial results&lt;/P&gt;
&lt;PRE&gt;Obs    row    col    number    string

  1     1       1        6     FIX.3.3
  2     1       2        5     1057
  3     1       3       25     8
  4     1       4       24     798
  5     1       5       55     RBCC_MID_PROD
  6     1       6       56     TOP_MUD_PROD
  7     1       7       33     N
  8     1       8       52     20210915-12:38:16.753
  9     2       1       24     802
 10     2       2        5     1079
 11     2       3       25     8
 12     2       4        6     FIX.3.3
 13     2       5       55     RBCC_MID_PROD
 14     2       6       56     TOP_MUD_PROD
 15     2       7       33     N
 16     2       8       52     20210915-12:39:50.053
 17     2       9      115     XPAS&lt;/PRE&gt;
&lt;P&gt;What is the meaning of the rows?&lt;/P&gt;
&lt;P&gt;Does the order on the line have any meaning?&lt;/P&gt;
&lt;P&gt;What is the meaning of the numbers in front of the equal signs?&lt;BR /&gt;What is the meaning of the text after the equal signs?&lt;/P&gt;
&lt;P&gt;Do you want to reduce it back to the same number of rows?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort; by row number col ; run;
proc transpose data=tall out=wide(drop=_name_) prefix=VAR;
  by row;
  id number;
  var string;
run;
proc print data=wide;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;Obs  row  VAR5   VAR6    VAR24  VAR25  VAR33          VAR52              VAR55         VAR56      VAR115  VAR1133  VAR95   VAR8101  VAR8115

 1    1   1057  FIX.3.3   798     8      N    20210915-12:38:16.753  RBCC_MID_PROD  TOP_MUD_PROD
 2    2   1079  FIX.3.3   802     8      N    20210915-12:39:50.053  RBCC_MID_PROD  TOP_MUD_PROD   XPAS
 3    3   1095  FIX.3.3   803     8      N    20210915-12:39:50.139  RBCC_MID_PROD  TOP_MID_PROD   XNAS      G
 4    4   1192  FIX.3.3   837     8      N    20210915-12:56:23.691  RBCC_MID_PROD  TOP_MUD_PROD   XNYS      G     stiev    CARE
 5    5   1189  FIX.3.3   844     8      N    20210915-12:59:36.825  RBCC_TOP_PROD  TOP_MUD_PROD   XPAS      G     mwonka   CARE      AOZ&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Oct 2021 03:57:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775307#M246445</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-20T03:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775373#M246469</link>
      <description>&lt;PRE&gt;options validvarname=any;
data want;
infile cards dlm='  ;' truncover;
input 
'6'n= $100. 
'5'n= $100.
'25'n= $100.
'95'n= $100.
'24'n= $100.
'55'n= $100.
'56'n= $100.
'33'n= $100.
'52'n= $100.
'115'n= $100.
'1133'n= $100.
'8101'n= $100.
'8115'n= $100.
;
cards4;
6=FIX.3.3; 5=1057; 25=8; 24=798; 55=RBCC_MID_PROD; 56=TOP_MUD_PROD; 33=N; 52=20210915-12:38:16.753; 
24=802; 5=1079; 25=8; 6=FIX.3.3; 55=RBCC_MID_PROD; 56=TOP_MUD_PROD; 33=N; 52=20210915-12:39:50.053; 115=XPAS; 
6=FIX.3.3; 5=1095; 25=8; 24=803; 55=RBCC_MID_PROD; 56=TOP_MID_PROD; 33=N; 52=20210915-12:39:50.139; 115=XNAS; 1133=G; 
24=837; 5=1192; 25=8; 95=stiev; 6=FIX.3.3; 55=RBCC_MID_PROD; 56=TOP_MUD_PROD; 33=N; 52=20210915-12:56:23.691; 115=XNYS; 1133=G; 8101=CARE; 
6=FIX.3.3; 5=1189; 25=8; 95=mwonka; 24=844; 55=RBCC_TOP_PROD; 56=TOP_MUD_PROD; 33=N; 52=20210915-12:59:36.825; 115=XPAS; 1133=G; 8101=CARE; 8115=AOZ; 
;;;;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Oct 2021 11:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775373#M246469</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-20T11:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775453#M246499</link>
      <description>&lt;P&gt;Super User Ballard,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the response.&amp;nbsp; There are over 1 million of the "6=" variables in the original data set.&amp;nbsp; All of the variable names begin with "X=" where X is an integer (number).&amp;nbsp; I only need to use 15 specific variables (columns) for my analysis.&amp;nbsp; The tricky part is that not all columns are populated for every row (transaction).&amp;nbsp; I am thinking the scan() function may need to be utilized.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The length and values for each variable differs, but it is fine to use character values for all columns as the numbers have meaning behind them via a different metadata file.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 19:37:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775453#M246499</guid>
      <dc:creator>emssas</dc:creator>
      <dc:date>2021-10-20T19:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775499#M246515</link>
      <description>&lt;P&gt;Super User Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the response.&amp;nbsp; Here are the answers to your questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What is the meaning of the rows&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;For example, "6=FIX3.3" should read 6 as the column name and FIX3.3 as the row value.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Does the order on the line have any meaning&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;Order does not have any meaning.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What is the meaning of the numbers in front of the equal signs&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;The meaning of the numbers in front of the equal signs is merely the column name.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;What is the meaning of the text after the equal signs&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;The meaning of the text after the equal signs is the row value.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Do you want to reduce it back to the same number of rows&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;Yes, I would like to reduce it back to the same number of rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 19:33:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775499#M246515</guid>
      <dc:creator>emssas</dc:creator>
      <dc:date>2021-10-20T19:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775500#M246516</link>
      <description>&lt;P&gt;Super User Ksharp,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the response.&amp;nbsp; Your code is great.&amp;nbsp; However, the actual data set contains over 1 million rows of data.&amp;nbsp; Therefore, manually inputting cards or datalines is not feasible.&amp;nbsp; Do you have any suggestions for me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 19:36:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775500#M246516</guid>
      <dc:creator>emssas</dc:creator>
      <dc:date>2021-10-20T19:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775504#M246518</link>
      <description>&lt;P&gt;DATALINES (also known as CARDS) are used here to share examples of data to demonstrate the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To read from an existing text file use the INFILE statement and replace the DATALINES; statement and the lines of data with a RUN: statement instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   infile 'myfile.txt' .... ;
   ...
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the following things are true:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;None of the values contain either the = or the ; character&lt;/LI&gt;
&lt;LI&gt;None of the values are totally empty (only spaces)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Then you can read the NAME/VALUE pairs directly by using both = and ; as delmiters.&lt;/P&gt;
&lt;P&gt;Read the values into a tall structure with NAME as one variable and VALUE as another.&lt;/P&gt;
&lt;P&gt;You can even add an IF statement to only output the NAME values you want to use in this dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tall;
  infile 'myfile.xt' dlm='=;' truncover ;
  length row 8 name $8 value $50 ;
  row + 1;
  do until(name=' ');
    input name value @ ;
    if name in ('5','6','234') then output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you can use TRANSPOSE to convert it back into one observation (if you need that).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=tall out=wide(drop=_name_) prefix=var;
  by row;
  id name;
  var value;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might want to put use a WHERE statement in the PROC TRANSPOSE step to do the filtering of variables instead of using the IF/THEN in the first step. Then you can keep all of the data in the TALL dataset and create different subsets from it for other analyses later without having to go back to the raw text file.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 19:52:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775504#M246518</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-20T19:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775612#M246558</link>
      <description>As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; point out using INFILE statement to replace CARDS .&lt;BR /&gt;If you need all the column name ,you need go through this TXT file and using a macro variable to hold them .</description>
      <pubDate>Thu, 21 Oct 2021 11:47:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775612#M246558</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-21T11:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775626#M246565</link>
      <description>&lt;UL&gt;
&lt;LI&gt;Don't use non-standard names that force you to always use name literals; an erroneous omitting of the ''n can lead to funny results&lt;/LI&gt;
&lt;LI&gt;Since you need to parse the input anyway, take the opportunity to set correct attributes of variables immediately&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile datalines dlm=';' truncover ;
length
  item $100
  name $5
  value $95
  var5 $50
  var6 $50
  var52 8
;
format
  var52 e8601dt23.3
;
input item @;
do while (item ne " ");
  name = scan(item,1,"=");
  value = scan(item,2,"=");
  select (name);
    when ("5") var5 = value;
    when ("6") var6 = value;
    when ("52") var52 = dhms(input(scan(value,1,"-"),yymmdd8.),0,0,input(scan(value,2,"-"),time12.));
    otherwise;
  end;
  input item @;
end;
drop item name value;
datalines4;
6=FIX.3.3; 5=1057; 25=8; 24=798; 55=RBCC_MID_PROD; 56=TOP_MUD_PROD; 33=N; 52=20210915-12:38:16.753; 
24=802; 5=1079; 25=8; 6=FIX.3.3; 55=RBCC_MID_PROD; 56=TOP_MUD_PROD; 33=N; 52=20210915-12:39:50.053; 115=XPAS; 
6=FIX.3.3; 5=1095; 25=8; 24=803; 55=RBCC_MID_PROD; 56=TOP_MID_PROD; 33=N; 52=20210915-12:39:50.139; 115=XNAS; 1133=G; 
24=837; 5=1192; 25=8; 95=stiev; 6=FIX.3.3; 55=RBCC_MID_PROD; 56=TOP_MUD_PROD; 33=N; 52=20210915-12:56:23.691; 115=XNYS; 1133=G; 8101=CARE; 
6=FIX.3.3; 5=1189; 25=8; 95=mwonka; 24=844; 55=RBCC_TOP_PROD; 56=TOP_MUD_PROD; 33=N; 52=20210915-12:59:36.825; 115=XPAS; 1133=G; 8101=CARE; 8115=AOZ;
;;;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Remove the DATALINES block, and replace the DATALINES keyword in the INFILE statement with the path to your file.&lt;/P&gt;
&lt;P&gt;Add additional definitions (LENGTH, FORMAT) and entries in the SELECT as needed.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 12:12:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/775626#M246565</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-21T12:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/776985#M247130</link>
      <description>&lt;P&gt;Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;Thanks for the reply.&amp;nbsp; I used your code, which worked very well on my small dataset.&amp;nbsp; However, when I run the code on a text (.log) file that contains 10,500+ rows of data, I get an empty data set.&amp;nbsp; Here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data fixerdata;
infile '\\My Documents\prod.log' dlm=';' truncover;
length
    item $100
    name $5
    value $95
    var8001 $20
    var17 $30
    var11106 $2
    var54 $4
    var9713 $6
    var60 8
    var32 $4
    var120 $4
    var31 6.11
    var15 $4
   var8147 $100
   var8100 $15
   var55 $5
   var65 $10
;
format
   var60 e8601dt25
;
input item @;
do while (item ne " ");
    name = scan(item,1,"=");
    value = scan(item,2,"=");
    select (name);
        when ("8001") var8001 = value;
        when ("17") var17 = value;
        when ("11106") var11106 = value;
        when ("54") var54 = value;
        when ("9713") var9713 = value;
        when ("60") var60 = dhms(input(scan(value,1,"-"),yymmdd8.),0,0,input(scan(value,2,"-"),time12.));
        when ("32") var32 = value;
        when ("120") var120 = value;
        when ("31") var31 = value;
        when ("15") var15 = value;
        when ("8147") var8147 = value;
        when ("8100") var8100 = value;
        when ("55") var55 = value;
        when ("65") var65 = value;
        otherwise;
    end;
    input item @;
end;
drop item name value;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;After I run the above code, I get this output in SAS Enterprise Guide 7.1:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      63:22   
NOTE: Variable e8601dt25 is uninitialized.
NOTE: The infile '\PROD.log' is:
      Filename=\\PROD.log,
      RECFM=V,LRECL=32767,File Size (bytes)=10750433,
      Last Modified=25Oct2021:11:11:42,
      Create Time=27Oct2021:14:23:26

NOTE: 10567 records were read from the infile '\\My Documents\PROD.log'.
      The minimum record length was 90.
      The maximum record length was 2055.
NOTE: The data set WORK.FIXERDATA has 10567 observations and 14 variables.
NOTE: DATA statement used (Total process time):
      real time           0.05 seconds
      cpu time            0.04 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="emssas_0-1635432707280.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65130i671407D90242E352/image-size/medium?v=v2&amp;amp;px=400" role="button" title="emssas_0-1635432707280.png" alt="emssas_0-1635432707280.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Please advise!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 15:09:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/776985#M247130</guid>
      <dc:creator>emssas</dc:creator>
      <dc:date>2021-10-28T15:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/776990#M247134</link>
      <description>&lt;P&gt;The SAS log will show more information. It should show the number of lines read from the text file and the length of the longest and shortest.&amp;nbsp; From your output looks like there is only one line and it did not contain any of those key names.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 15:00:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/776990#M247134</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-28T15:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/776995#M247136</link>
      <description>&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the log file info:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      63:22   
NOTE: Variable e8601dt25 is uninitialized.
NOTE: The infile '\\\My Documents\PROD.log' is:
      Filename=\\My Documents\PROD.log,
      RECFM=V,LRECL=32767,File Size (bytes)=10750433,
      Last Modified=25Oct2021:11:11:42,
      Create Time=27Oct2021:14:23:26

NOTE: 10567 records were read from the infile '\\\My Documents\PROD.log'.
      The minimum record length was 90.
      The maximum record length was 2055.
NOTE: The data set WORK.FIXERDATA has 10567 observations and 14 variables.
NOTE: DATA statement used (Total process time):
      real time           0.05 seconds
      cpu time            0.04 seconds&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Oct 2021 15:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/776995#M247136</guid>
      <dc:creator>emssas</dc:creator>
      <dc:date>2021-10-28T15:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/777015#M247148</link>
      <description>&lt;P&gt;Modify the code for testing:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fixerdata;
infile '\\My Documents\prod.log' dlm=';' truncover obs=10;
length
    item $100
    name $5
    value $95
    var8001 $20
    var17 $30
    var11106 $2
    var54 $4
    var9713 $6
    var60 8
    var32 $4
    var120 $4
    var31 6.11
    var15 $4
   var8147 $100
   var8100 $15
   var55 $5
   var65 $10
;
format
   var60 e8601dt25.
;
input item @;
put _infile_;
do while (item ne " ");
    name = scan(item,1,"=");
    value = scan(item,2,"=");
    select (name);
        when ("8001") var8001 = value;
        when ("17") var17 = value;
        when ("11106") var11106 = value;
        when ("54") var54 = value;
        when ("9713") var9713 = value;
        when ("60") var60 = dhms(input(scan(value,1,"-"),yymmdd8.),0,0,input(scan(value,2,"-"),time12.));
        when ("32") var32 = value;
        when ("120") var120 = value;
        when ("31") var31 = value;
        when ("15") var15 = value;
        when ("8147") var8147 = value;
        when ("8100") var8100 = value;
        when ("55") var55 = value;
        when ("65") var65 = value;
        otherwise;
    end;
    input item @;
end;
drop item name value;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will put your first 10 lines to the log.&lt;/P&gt;
&lt;P&gt;Also note the dot I added in the FORMAT statement. The missing dot was the cause for the "uninitialized" message.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 15:45:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/777015#M247148</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-28T15:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/777031#M247158</link>
      <description>&lt;P&gt;Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&amp;nbsp; I ran the modified code and still am seeing blank values in the 10 rows.&amp;nbsp; Here is the log file with no errors and no warnings.&amp;nbsp; Here are the six Notes from the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      63:22   

NOTE: The infile '\My Documents\PROD.log' is:
      Filename=\\My Documents\PROD.log,
      RECFM=V,LRECL=32767,File Size (bytes)=10750433,
      Last Modified=25Oct2021:11:11:42,
      Create Time=27Oct2021:14:23:26

NOTE: 10 records were read from the infile '\\My Documents\PROD.log'.
      The minimum record length was 90.
      The maximum record length was 119.

NOTE: The data set WORK.FIXERDATA has 10 observations and 14 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here is a sample of what one line of input data (.log) file looks like in Notepad:&lt;/P&gt;&lt;PRE&gt;15=USD 17=00004885118TRTR1.1.1 31=779.530000 32=100 54=1 55=LML 60=20210414-14:47:46 65= 120=USD 8001=EXEC_FEW 8100= 8147=Xxxxxxxx.Xxxxxxx@XXXX.XXX 9713=815215 11106=40&lt;/PRE&gt;&lt;P&gt;In the input data, the 65= and 8100= have blank values and need to populate in the SAS output data as having blank values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 16:31:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/777031#M247158</guid>
      <dc:creator>emssas</dc:creator>
      <dc:date>2021-10-28T16:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/777035#M247161</link>
      <description>&lt;P&gt;That line is NOT using semi-colon between the name=value pairs.&amp;nbsp; It has some other character there. Is it a space? Or a tab?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 16:28:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/777035#M247161</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-10-28T16:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/777037#M247162</link>
      <description>&lt;P&gt;Good catch, Tom.&amp;nbsp; It is a space.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 16:32:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/777037#M247162</guid>
      <dc:creator>emssas</dc:creator>
      <dc:date>2021-10-28T16:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/777075#M247182</link>
      <description>&lt;P&gt;Which means you have to change the delimiter in the INFILE statement accordingly.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 17:54:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/777075#M247182</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-28T17:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/777134#M247199</link>
      <description>&lt;P&gt;Kurt,&lt;BR /&gt;&lt;BR /&gt;I did that, but I still am not seeing any records in the output data.&amp;nbsp; How should I change the delimiter in the infile statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 23:58:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/777134#M247199</guid>
      <dc:creator>emssas</dc:creator>
      <dc:date>2021-10-28T23:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing column names and corresponding rows from a messy text file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/777192#M247226</link>
      <description>&lt;P&gt;With the delimiter changed to a blank, my code works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fixerdata;
infile datalines dlm=' ' truncover obs=10;
length
    item $100
    name $5
    value $95
    var8001 $20
    var17 $30
    var11106 $2
    var54 $4
    var9713 $6
    var60 8
    var32 $4
    var120 $4
    var31 6.11
    var15 $4
   var8147 $100
   var8100 $15
   var55 $5
   var65 $10
;
format
   var60 e8601dt25.
;
input item @;
put _infile_;
do while (item ne " ");
    name = scan(item,1,"=");
    value = scan(item,2,"=");
    select (name);
        when ("8001") var8001 = value;
        when ("17") var17 = value;
        when ("11106") var11106 = value;
        when ("54") var54 = value;
        when ("9713") var9713 = value;
        when ("60") var60 = dhms(input(scan(value,1,"-"),yymmdd8.),0,0,input(scan(value,2,"-"),time12.));
        when ("32") var32 = value;
        when ("120") var120 = value;
        when ("31") var31 = value;
        when ("15") var15 = value;
        when ("8147") var8147 = value;
        when ("8100") var8100 = value;
        when ("55") var55 = value;
        when ("65") var65 = value;
        otherwise;
    end;
    input item @;
end;
drop item name value;
datalines;
15=USD 17=00004885118TRTR1.1.1 31=779.530000 32=100 54=1 55=LML 60=20210414-14:47:46 65= 120=USD 8001=EXEC_FEW 8100= 8147=Xxxxxxxx.Xxxxxxx@XXXX.XXX 9713=815215 11106=40
;

proc print data=fixerdata noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;var8001	var17	var11106	var54	var9713	var60	var32	var120	var31	var15	var8147	var8100	var55	var65
EXEC_FEW	00004885118TRTR1.1.1	40	1	815215	2021-04-14T14:47:46	100	USD	779.530	USD	Xxxxxxxx.Xxxxxxx@XXXX.XXX	 	LML	 &lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Oct 2021 08:50:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Parsing-column-names-and-corresponding-rows-from-a-messy-text/m-p/777192#M247226</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-29T08:50:34Z</dc:date>
    </item>
  </channel>
</rss>

