<?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: Create dataset from external file that has no delimiters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-dataset-from-external-file-that-has-no-delimiters/m-p/240843#M44515</link>
    <description>Thanks, RW. I am new to SAS and am trying to solve a few challenging problems as practice. This question was part of that exercise. I will keep your advice in mind for real time scenarios.</description>
    <pubDate>Fri, 25 Dec 2015 00:59:43 GMT</pubDate>
    <dc:creator>ramm</dc:creator>
    <dc:date>2015-12-25T00:59:43Z</dc:date>
    <item>
      <title>Create dataset from external file that has no delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-dataset-from-external-file-that-has-no-delimiters/m-p/240763#M44474</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a text file that is similar to the one below (1). It does not have any demiliers and it has the variables: name,sex,age,weight, height. Could you kindly help with how this can be imported into a SAS dataset as shown in (2) ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I)&lt;/P&gt;&lt;P&gt;External text file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JanetF1562.5112.5&lt;BR /&gt;MaryF1566.5112&lt;BR /&gt;CarolF1462.8102.5&lt;BR /&gt;JudyF1464.390&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2)&lt;/P&gt;&lt;P&gt;Dataset table after importing into SAS should look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Janet F 15 62.5 112.5&lt;BR /&gt;Mary F 15 66.5 112&lt;BR /&gt;Carol F 14 62.8 102.5&lt;BR /&gt;Judy F 14 64.3 90&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;ramm&lt;/P&gt;</description>
      <pubDate>Thu, 24 Dec 2015 04:10:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-dataset-from-external-file-that-has-no-delimiters/m-p/240763#M44474</guid>
      <dc:creator>ramm</dc:creator>
      <dc:date>2015-12-24T04:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Create dataset from external file that has no delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-dataset-from-external-file-that-has-no-delimiters/m-p/240765#M44476</link>
      <description>&lt;P&gt;PRX to the rescue! Assuming that age always has two digits and weight always has a single decimal :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
length str $100 name $24 sex $1;
if not prx1 then prx1 + prxparse("/(\D+)(M|F)(\d\d)(\d+\.\d)(\S+)/");
input str;
if prxmatch(prx1,str) then do;
    name = prxposn(prx1,1,str);
    sex = prxposn(prx1,2,str);
    age = input(prxposn(prx1,3,str), best.);
    weight = input(prxposn(prx1,4,str), best.);
    height = input(prxposn(prx1,5,str), best.);
    end;
drop prx1;
datalines;
JanetF1562.5112.5
MaryF1566.5112
CarolF1462.8102.5
JudyF1464.390
;

proc print data=test noobs; run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Dec 2015 04:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-dataset-from-external-file-that-has-no-delimiters/m-p/240765#M44476</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-12-24T04:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create dataset from external file that has no delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-dataset-from-external-file-that-has-no-delimiters/m-p/240767#M44478</link>
      <description>Thanks so much, PG ! Will work pn understanding PRX now.</description>
      <pubDate>Thu, 24 Dec 2015 05:02:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-dataset-from-external-file-that-has-no-delimiters/m-p/240767#M44478</guid>
      <dc:creator>ramm</dc:creator>
      <dc:date>2015-12-24T05:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create dataset from external file that has no delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-dataset-from-external-file-that-has-no-delimiters/m-p/240768#M44479</link>
      <description>&lt;P&gt;You are welcome. Here is a description of the pattern, to get you started&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token string"&gt;"/(\D+)(M|F)(\d\d)(\d+\.\d)(\S+)/"&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;One or more non-digits, followed by&lt;/P&gt;
&lt;P&gt;M or F, followed by&lt;/P&gt;
&lt;P&gt;two digits, followed by&lt;/P&gt;
&lt;P&gt;one or more digits, followed by a period, followed by a single digit, followed by&lt;/P&gt;
&lt;P&gt;one or more non-space characters&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;each pair of parentheses defines a capture buffer (to be extracted with function prxposn)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Dec 2015 05:13:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-dataset-from-external-file-that-has-no-delimiters/m-p/240768#M44479</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-12-24T05:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create dataset from external file that has no delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-dataset-from-external-file-that-has-no-delimiters/m-p/240785#M44488</link>
      <description>&lt;P&gt;More importantly, why do you have a file where you would be guessing which parts are data. &amp;nbsp;You can fix it by fixing width as examples given above by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats﻿&lt;/a&gt;. &amp;nbsp;However, what if those assumptions do not work for all data, or it changes. &amp;nbsp;Personally I would go back to the vendor and ask them to provide an easy to use robust file. &amp;nbsp;Correction at the source of issues will save you time in the long run.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Dec 2015 10:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-dataset-from-external-file-that-has-no-delimiters/m-p/240785#M44488</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-12-24T10:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create dataset from external file that has no delimiters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-dataset-from-external-file-that-has-no-delimiters/m-p/240843#M44515</link>
      <description>Thanks, RW. I am new to SAS and am trying to solve a few challenging problems as practice. This question was part of that exercise. I will keep your advice in mind for real time scenarios.</description>
      <pubDate>Fri, 25 Dec 2015 00:59:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-dataset-from-external-file-that-has-no-delimiters/m-p/240843#M44515</guid>
      <dc:creator>ramm</dc:creator>
      <dc:date>2015-12-25T00:59:43Z</dc:date>
    </item>
  </channel>
</rss>

