<?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: Spaces in a string variable in a .dat file causing column/truncating issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Spaces-in-a-string-variable-in-a-dat-file-causing-column/m-p/653088#M196147</link>
    <description>&lt;P&gt;Do you know if this file has any history of editing or conversion?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A fair number of applications that use the .DAT extension create TAB delimited text, which this isn't. But if someone did a search an replace on tab characters replacing them with spaces (2 is my guess) you might get something like this.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jun 2020 06:59:14 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-06-04T06:59:14Z</dc:date>
    <item>
      <title>Spaces in a string variable in a .dat file causing column/truncating issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spaces-in-a-string-variable-in-a-dat-file-causing-column/m-p/653061#M196136</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The final two columns are causing a problem with my import. The full "room type" name is not appearing, only a small portion (if any) and the room rate column (final column) is sometimes appearing in the "room type" column. I believe the issue is tied to the spaces in the room type column and I am not coding appropriately to handle them. Any recommendations? I have searched a ton, and the options I have found have not worked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Current code is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA Hotel;&lt;BR /&gt;INFILE 'E:\Users\skm190000\Desktop\Datasets\Hotel.dat';&lt;BR /&gt;informat&lt;BR /&gt;roomnumber 4.&lt;BR /&gt;guests$ 1.&lt;BR /&gt;CI_month 1.&lt;BR /&gt;CI_day 2.&lt;BR /&gt;CI_year 4.&lt;BR /&gt;CO_month 1.&lt;BR /&gt;CO_day 2.&lt;BR /&gt;CO_year 4.&lt;BR /&gt;Internet$ 3.&lt;BR /&gt;DaysInternetUse 2.&lt;BR /&gt;RoomType$ 13.&lt;BR /&gt;RoomRate 3.&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;iNPUT&lt;BR /&gt;roomnumber&lt;BR /&gt;guests$&lt;BR /&gt;CI_month&lt;BR /&gt;CI_day&lt;BR /&gt;CI_year&lt;BR /&gt;CO_month&lt;BR /&gt;CO_day&lt;BR /&gt;CO_year&lt;BR /&gt;Internet$&lt;BR /&gt;DaysInternetUse&lt;BR /&gt;RoomType$&lt;BR /&gt;RoomRate&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed the file from .dat to txt for this request. so code above will have a shift in the file name.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 04:54:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spaces-in-a-string-variable-in-a-dat-file-causing-column/m-p/653061#M196136</guid>
      <dc:creator>Samurai</dc:creator>
      <dc:date>2020-06-04T04:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Spaces in a string variable in a .dat file causing column/truncating issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spaces-in-a-string-variable-in-a-dat-file-causing-column/m-p/653063#M196137</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Samurai_0-1591246924319.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/40332iE5507D93A93D9088/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Samurai_0-1591246924319.png" alt="Samurai_0-1591246924319.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 05:02:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spaces-in-a-string-variable-in-a-dat-file-causing-column/m-p/653063#M196137</guid>
      <dc:creator>Samurai</dc:creator>
      <dc:date>2020-06-04T05:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Spaces in a string variable in a .dat file causing column/truncating issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spaces-in-a-string-variable-in-a-dat-file-causing-column/m-p/653066#M196139</link>
      <description>&lt;P&gt;You also have an issue with the third last column being missing without any delimiter.&lt;/P&gt;
&lt;P&gt;Since you almost have a column-aligned data, something like this might work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input
    ROOMNUMBER
    GUESTS $
    CI_MONTH
    CI_DAY
    CI_YEAR
    CO_MONTH
    CO_DAY
    CO_YEAR
    INTERNET $
@49 DAYSINTERNETUSE 3.
    ROOMTYPE &amp;amp; $
    ROOMRATE
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214312"&gt;@49&lt;/a&gt; positions the pointer to force reading at that position even if there is no data.&lt;/P&gt;
&lt;P&gt;&amp;amp; tells SAS that a single space does not mark the end of the string, and that a double space must be found.&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 05:27:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spaces-in-a-string-variable-in-a-dat-file-causing-column/m-p/653066#M196139</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-06-04T05:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Spaces in a string variable in a .dat file causing column/truncating issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spaces-in-a-string-variable-in-a-dat-file-causing-column/m-p/653073#M196144</link>
      <description>&lt;P&gt;Thank you! This will work. I am going to play around more to see if I can get the full room type name to appear, but this fixes my data placement issues! I really appreciate you taking the time to guide me!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 06:00:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spaces-in-a-string-variable-in-a-dat-file-causing-column/m-p/653073#M196144</guid>
      <dc:creator>Samurai</dc:creator>
      <dc:date>2020-06-04T06:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: Spaces in a string variable in a .dat file causing column/truncating issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spaces-in-a-string-variable-in-a-dat-file-causing-column/m-p/653088#M196147</link>
      <description>&lt;P&gt;Do you know if this file has any history of editing or conversion?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A fair number of applications that use the .DAT extension create TAB delimited text, which this isn't. But if someone did a search an replace on tab characters replacing them with spaces (2 is my guess) you might get something like this.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 06:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spaces-in-a-string-variable-in-a-dat-file-causing-column/m-p/653088#M196147</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-04T06:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Spaces in a string variable in a .dat file causing column/truncating issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Spaces-in-a-string-variable-in-a-dat-file-causing-column/m-p/653102#M196153</link>
      <description>&lt;P&gt;Two positions fixed it for me:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input
  roomnumber
  guests $
  CI_month
  CI_day
  CI_year
  CO_month
  CO_day
  CO_year
  Internet $
  @49 DaysInternetUse 3.
  @53 RoomType $16.
  RoomRate
;
datalines;
211    3    2  7  2014    2  11  2014    NO         Deluxe Suite    295
214    2    2  2  2014    2  12  2014    NO         Basic no view    75
216    4    2  2  2014    2  13  2014    NO         Suite           255
220    5    2  3  2014    2  12  2014    YES    2    Basic w/view   155
221    3    2  3  2014    2  12  2014    NO         Luxury          195
223    5    2  7  2014    2  13  2014    NO         Suite           255
238    4    1  31  2014    2  13  2014    YES    10    Basic w/view 155
241    1    2  1  2014    2  13  2014    YES    3    Luxury         195
244    5    2  3  2014    2  12  2014    YES    9    Deluxe Suite   295
247    4    2  7  2014    2  11  2014    YES    4    Basic no view   75
248    4    2  8  2014    2  13  2014    YES    5    Basic no view   75
253    3    2  2  2014    2  12  2014    YES    7    Suite          255
255    5    2  8  2014    2  13  2014    NO         Basic w/view    155
270    1    2  4  2014    2  12  2014    NO         Deluxe Suite    295
272    2    2  2  2014    2  11  2014    YES    7    Suite          255
275    1    2  2  2014    2  10  2014    NO         Basic no view    75
276    5    2  10  2014    2  12  2014    NO         Basic w/view   155
281    1    2  9  2014    2  10  2014    NO         Basic w/view    155
283    1    2  8  2014    2  11  2014    NO         Deluxe Suite    295
288    3    2  2  2014    2  13  2014    NO         Suite           255
293    4    2  7  2014    2  11  2014    YES    4    Basic no view   75
294    5    2  1  2014    2  12  2014    YES    3    Basic w/view   155
298    6    2  1  2014    2  10  2014    NO         Suite           255
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jun 2020 08:05:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Spaces-in-a-string-variable-in-a-dat-file-causing-column/m-p/653102#M196153</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-04T08:05:15Z</dc:date>
    </item>
  </channel>
</rss>

