<?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: delimiter  # in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780221#M248582</link>
    <description>Thanks,&lt;BR /&gt;I found that in some observations it happended that each observations is in 2 rows (instead of 1).&lt;BR /&gt;What is the way to tell SAS to continue add data to the observation?&lt;BR /&gt;I know the using of @@  ut may you show how to use it in the  following :&lt;BR /&gt;/****A*****/&lt;BR /&gt;data work.example;&lt;BR /&gt;length cat1 cat2 $200 num1 3. ;&lt;BR /&gt;infile '/home/mydata/quick_example.txt'&lt;BR /&gt;delimiter='#' dsd truncover firstobs=2;&lt;BR /&gt;input cat1 cat2 num1;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/****B***************/&lt;BR /&gt;proc import file='/path'&lt;BR /&gt;    out=work.shoes&lt;BR /&gt;    dbms=dlm;&lt;BR /&gt;delimiter='#';&lt;BR /&gt;run;</description>
    <pubDate>Mon, 15 Nov 2021 11:36:10 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2021-11-15T11:36:10Z</dc:date>
    <item>
      <title>delimiter  #</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780204#M248577</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to import tst file with delimiter #&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import file='/path'
    out=work.shoes
    dbms='#';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I get an error&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: DBMS type # not valid for import.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the way to define that the delimiter is # ( sladder)&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 09:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780204#M248577</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-11-15T09:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: delimiter  #</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780206#M248579</link>
      <description>&lt;P&gt;The correct way to do it is this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import file='/path'
    out=work.shoes
    dbms=dlm;
delimiter='#';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Nov 2021 09:47:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780206#M248579</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2021-11-15T09:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: delimiter  #</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780211#M248581</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;, you can read a file with custom delimiter using the data step's infile statement. See below a simple example. I uploaded a dummy text file into SAS Studio and read in via data step. Note I added a header which I ignore in the infile statement by setting which observation to start at.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HarrySnart_0-1636970623047.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65700iBF016CB7DDF69DE6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HarrySnart_0-1636970623047.png" alt="HarrySnart_0-1636970623047.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Read inputs from .txt file with # delimiter;
data work.example;
length cat1 cat2 $200 num1 3. ;
infile '/home/mydata/quick_example.txt'
delimiter='#' dsd truncover firstobs=2;
input cat1 cat2 num1;
run;

*Print example output;
proc print data=work.example;title 'Parsed Infile with # Delimiter';run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HarrySnart_1-1636970822187.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65701iD85EE0C254528729/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HarrySnart_1-1636970822187.png" alt="HarrySnart_1-1636970822187.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Hope this helps answer your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 10:07:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780211#M248581</guid>
      <dc:creator>HarrySnart</dc:creator>
      <dc:date>2021-11-15T10:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: delimiter  #</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780221#M248582</link>
      <description>Thanks,&lt;BR /&gt;I found that in some observations it happended that each observations is in 2 rows (instead of 1).&lt;BR /&gt;What is the way to tell SAS to continue add data to the observation?&lt;BR /&gt;I know the using of @@  ut may you show how to use it in the  following :&lt;BR /&gt;/****A*****/&lt;BR /&gt;data work.example;&lt;BR /&gt;length cat1 cat2 $200 num1 3. ;&lt;BR /&gt;infile '/home/mydata/quick_example.txt'&lt;BR /&gt;delimiter='#' dsd truncover firstobs=2;&lt;BR /&gt;input cat1 cat2 num1;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/****B***************/&lt;BR /&gt;proc import file='/path'&lt;BR /&gt;    out=work.shoes&lt;BR /&gt;    dbms=dlm;&lt;BR /&gt;delimiter='#';&lt;BR /&gt;run;</description>
      <pubDate>Mon, 15 Nov 2021 11:36:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780221#M248582</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-11-15T11:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: delimiter  #</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780223#M248584</link>
      <description>&lt;P&gt;The code you provided is not working well, I get one column only&lt;/P&gt;
&lt;P&gt;This code was created by using import wizard and it works well except of some problems:&lt;/P&gt;
&lt;P&gt;1-IF the observation is written on 2 rows (instead of 1 ) then It doesnt take the data correctly.&lt;/P&gt;
&lt;P&gt;May you please explain why your code is not working&amp;nbsp; well?&lt;/P&gt;
&lt;P&gt;How can you adjust your code please?&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WORK.kelet;
obs=_n_;
    LENGTH
        F1               $ 55
        F2                 8
        F3                 8
        F4                 8
        F5                 8
        F6                 8
        F7                 8
        F8                 8
        F9                 8
        F10              $ 26
        F11                8
        F12                8
        F13              $ 65
        F14              $ 14
        F15              $ 90
        F16              $ 81
        F17                8
        F18              $ 1 ;
    FORMAT
        F1               $CHAR55.
        F2               BEST9.
        F3               BEST9.
        F4               BEST4.
        F5               DDMMYY10.
        F6               DDMMYY10.
        F7               BEST17.
        F8               BEST16.
        F9               BEST3.
        F10              $CHAR26.
        F11              BEST4.
        F12              BEST9.
        F13              $CHAR65.
        F14              $CHAR14.
        F15              $CHAR90.
        F16              $CHAR81.
        F17              BEST9.
        F18              $CHAR1. ;
    INFORMAT
        F1               $CHAR55.
        F2               BEST9.
        F3               BEST9.
        F4               BEST4.
        F5               DDMMYY10.
        F6               DDMMYY10.
        F7               BEST17.
        F8               BEST16.
        F9               BEST3.
        F10              $CHAR26.
        F11              BEST4.
        F12              BEST9.
        F13              $CHAR65.
        F14              $CHAR14.
        F15              $CHAR90.
        F16              $CHAR81.
        F17              BEST9.
        F18              $CHAR1. ;
    INFILE 'path'
        LRECL=285
        ENCODING="HEBREW"
        TERMSTR=CRLF
        DLM='7F'x
        MISSOVER
        DSD ;
    INPUT
        F1               : $CHAR55.
        F2               : ?? BEST9.
        F3               : ?? BEST9.
        F4               : ?? BEST4.
        F5               : ?? DDMMYY10.
        F6               : ?? DDMMYY10.
        F7               : ?? COMMA17.
        F8               : ?? COMMA16.
        F9               : ?? BEST3.
        F10              : $CHAR26.
        F11              : ?? BEST4.
        F12              : ?? BEST9.
        F13              : $CHAR65.
        F14              : $CHAR14.
        F15              : $CHAR90.
        F16              : $CHAR81.
        F17              : ?? BEST9.
        F18              : $CHAR1. ;
RUN;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Nov 2021 12:00:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780223#M248584</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-11-15T12:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: delimiter  #</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780225#M248585</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;please can you share a few lines of dummy data as an example to the data you're trying to import? Using the delimiter option in the infile the data step expects the same number of columns defined on each row. If your data is very messy you can alternatively read the lines into a single row and then subset items using scan() for example, I've done this previously where some rows only contain a subset of the total expected columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 12:20:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780225#M248585</guid>
      <dc:creator>HarrySnart</dc:creator>
      <dc:date>2021-11-15T12:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: delimiter  #</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780232#M248589</link>
      <description>&lt;P&gt;You tell the INPUT statement to go to a new line when reading a delimited file the same way you would when reading any text file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The character / in an input statement means to go to a new line.&amp;nbsp; So if you text file is structured to have three fields on the first line and two on the second then your code to read it might look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   infile 'myfile.txt' dlm='#' ;
   length var1 var2 8 var3 $20 var4 $10 var5 8 var6 $30 ;
   input var1 var2 var3 / var4 var 5;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Nov 2021 13:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780232#M248589</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-15T13:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: delimiter  #</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780256#M248600</link>
      <description>Thanks.&lt;BR /&gt;The source data file (txt with # delimiter) has 2.5 million observations.&lt;BR /&gt;In most of cases each observation is located in 1 row.&lt;BR /&gt;But, unfortunately sometimes the observation is located in 2 rows .&lt;BR /&gt;In such cases using proc report wizard was not good because sas created 2 observations instead of 1( please see before the code was generated by import wizard).&lt;BR /&gt;My question is how to solve this problem via the code I provided before.thanks</description>
      <pubDate>Mon, 15 Nov 2021 15:17:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780256#M248600</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-11-15T15:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: delimiter  #</title>
      <link>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780261#M248605</link>
      <description>&lt;P&gt;So you need to figure out WHY some of the observations are split between two records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are lucky it is just because when the file was written they used too short of a setting for the LRECL options and sometimes the last few fields were written to a new line.&amp;nbsp; In that case try reading the file with the FLOWOVER option instead of TRUNCOVER (or MISSOVER) option and perhaps it will automatically jump to the next line properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are unlucky it is because there were end of line characters in the value of one of the character variables in the observation.&amp;nbsp; That is harder for SAS to read and you will probably need to fix the file first.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Again if you are lucky the actual lines are terminated with CR+LF pair and the embedded line breaks are just single CR or single LF characters.&amp;nbsp; That you can fix by using the TERMSTR=CRLF option on the infile statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next level is that the fields that contain the end of line characters are quoted.&amp;nbsp; Then you can use a method like in this macro to create a version of the file that can be parsed.&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/replace_crlf.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/replace_crlf.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the fields with the end of line characters are not quoted then perhaps you can fix it by counting the number of delimiters.&amp;nbsp; There are examples on this forum of that solution also.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 15:47:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/delimiter/m-p/780261#M248605</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-15T15:47:28Z</dc:date>
    </item>
  </channel>
</rss>

