<?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: Newbie question on importing raw data with space as delimiter and space between names too in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Newbie-question-on-importing-raw-data-with-space-as-delimiter/m-p/546871#M8285</link>
    <description>&lt;P&gt;The solution would be to read the "fixed" values backwards first and then search for the stat1 value in the input record to determine where the last character of city is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  length city_name $30 stat1-stat3 8;
  input ;
  stat3 = input(scan(_infile_,-1),8.);
  stat2 = input(scan(_infile_,-2),8.);
  stat1 = input(scan(_infile_,-3),8.);
  city_name = substr(_infile_,1,find(_infile_,scan(_infile_,-3))-1);
  cards;
idaho  123  345  789
los angeles  234  567  890
papua new guniea  765  432  109
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your code would look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data stats2;
  infile "/folders/myfolders/datasets/sample1.dat" ;
  length city_name $30 stat1-stat3 8;
  input ;
  stat3 = input(scan(_infile_,-1),8.);
  stat2 = input(scan(_infile_,-2),8.);
  stat1 = input(scan(_infile_,-3),8.);
  city_name = substr(_infile_,1,find(_infile_,scan(_infile_,-3))-1);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 28 Mar 2019 12:24:40 GMT</pubDate>
    <dc:creator>MichaelLarsen</dc:creator>
    <dc:date>2019-03-28T12:24:40Z</dc:date>
    <item>
      <title>Newbie question on importing raw data with space as delimiter and space between names too</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Newbie-question-on-importing-raw-data-with-space-as-delimiter/m-p/546861#M8282</link>
      <description>&lt;P&gt;Hi. i have a raw data file that has names of cities in it, followed by some stats. the names of cities may be one-, two-, or three-word long. the words of the city name are separated by a space. the city name and other stats are separated by a double space. so it's like this:&lt;/P&gt;&lt;P&gt;idaho&amp;nbsp; 123&amp;nbsp; 345&amp;nbsp; 789&lt;/P&gt;&lt;P&gt;los angeles&amp;nbsp; 234&amp;nbsp; 567&amp;nbsp; 890&lt;/P&gt;&lt;P&gt;papua new guniea&amp;nbsp; 765&amp;nbsp; 432&amp;nbsp; 109&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;something like that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i thought i'd found the way around when i wrote a code like this (with dlm set to DOUBLE SPACE):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data stats2;&lt;BR /&gt;infile "/folders/myfolders/datasets/sample1.dat" dlm="&amp;nbsp; " dsd missover;&lt;BR /&gt;input city_name :$30. stat1 stat2 stat3;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it won't work. how can i go about it?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 12:01:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Newbie-question-on-importing-raw-data-with-space-as-delimiter/m-p/546861#M8282</guid>
      <dc:creator>Sach_sri</dc:creator>
      <dc:date>2019-03-28T12:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie question on importing raw data with space as delimiter and space between names too</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Newbie-question-on-importing-raw-data-with-space-as-delimiter/m-p/546867#M8283</link>
      <description>&lt;P&gt;Try dlmstr instead of dlm&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 12:16:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Newbie-question-on-importing-raw-data-with-space-as-delimiter/m-p/546867#M8283</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-03-28T12:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie question on importing raw data with space as delimiter and space between names too</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Newbie-question-on-importing-raw-data-with-space-as-delimiter/m-p/546870#M8284</link>
      <description>if each row ends with 3 numbers, read the row into a single field, pick out and remove the 3 numbers and what's left is the city name.</description>
      <pubDate>Thu, 28 Mar 2019 12:23:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Newbie-question-on-importing-raw-data-with-space-as-delimiter/m-p/546870#M8284</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2019-03-28T12:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie question on importing raw data with space as delimiter and space between names too</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Newbie-question-on-importing-raw-data-with-space-as-delimiter/m-p/546871#M8285</link>
      <description>&lt;P&gt;The solution would be to read the "fixed" values backwards first and then search for the stat1 value in the input record to determine where the last character of city is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  length city_name $30 stat1-stat3 8;
  input ;
  stat3 = input(scan(_infile_,-1),8.);
  stat2 = input(scan(_infile_,-2),8.);
  stat1 = input(scan(_infile_,-3),8.);
  city_name = substr(_infile_,1,find(_infile_,scan(_infile_,-3))-1);
  cards;
idaho  123  345  789
los angeles  234  567  890
papua new guniea  765  432  109
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your code would look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data stats2;
  infile "/folders/myfolders/datasets/sample1.dat" ;
  length city_name $30 stat1-stat3 8;
  input ;
  stat3 = input(scan(_infile_,-1),8.);
  stat2 = input(scan(_infile_,-2),8.);
  stat1 = input(scan(_infile_,-3),8.);
  city_name = substr(_infile_,1,find(_infile_,scan(_infile_,-3))-1);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Mar 2019 12:24:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Newbie-question-on-importing-raw-data-with-space-as-delimiter/m-p/546871#M8285</guid>
      <dc:creator>MichaelLarsen</dc:creator>
      <dc:date>2019-03-28T12:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie question on importing raw data with space as delimiter and space between names too</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Newbie-question-on-importing-raw-data-with-space-as-delimiter/m-p/546872#M8286</link>
      <description>&lt;P&gt;To complicated &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/24960"&gt;@MichaelLarsen&lt;/a&gt;&amp;nbsp; and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/144199"&gt;@tomrvincent&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  length city_name $30 stat1-stat3 8;
  infile datalines dlmstr='  ';
  input city_name stat1-stat3;

  datalines;
idaho  123  345  789
los angeles  234  567  890
papua new guniea  765  432  109
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Mar 2019 12:27:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Newbie-question-on-importing-raw-data-with-space-as-delimiter/m-p/546872#M8286</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-03-28T12:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie question on importing raw data with space as delimiter and space between names too</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Newbie-question-on-importing-raw-data-with-space-as-delimiter/m-p/546934#M8300</link>
      <description>&lt;P&gt;It helps to post TEXT data into a code box opened using the forum's {I} icon. The main message windows are likely to reformat text removing extra spaces and so your text example may not be as your actual file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also use the code box for Code and Log results for the same reason.&lt;/P&gt;
&lt;P&gt;Example: pasting an edited version of your data from my SAS editor into the main window.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000" face="SAS Monospace" size="2"&gt;idaho&lt;/FONT&gt; &lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;123&lt;/FONT&gt; &lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;345&lt;/FONT&gt; &lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;789&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;los angeles &lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;234&lt;/FONT&gt; &lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;567&lt;/FONT&gt; &lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;890&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;papua new guniea &lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;765&lt;/FONT&gt; &lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;432&lt;/FONT&gt; &lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;109&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;And pasting into a code box. Note the difference. This often means that data steps that read data as pasted into the main window&amp;nbsp; will not run with your actual data, or that code you paste will not read your inline data.&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;idaho        123  345  789
los angeles  234  567  890
papua new guniea  765  432  109

&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Newbie-question-on-importing-raw-data-with-space-as-delimiter/m-p/546934#M8300</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-28T15:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Newbie question on importing raw data with space as delimiter and space between names too</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Newbie-question-on-importing-raw-data-with-space-as-delimiter/m-p/546947#M8303</link>
      <description>&lt;P&gt;Thanks. It worked. I'll make a note of this. I'm sure other answers are bound to work too but with this one I had to change my code so little.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 16:39:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Newbie-question-on-importing-raw-data-with-space-as-delimiter/m-p/546947#M8303</guid>
      <dc:creator>Sach_sri</dc:creator>
      <dc:date>2019-03-28T16:39:01Z</dc:date>
    </item>
  </channel>
</rss>

