<?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: RAW Data import in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/RAW-Data-import/m-p/392781#M5952</link>
    <description>Thanks for your Reply,&lt;BR /&gt;But these codes are not working &lt;BR /&gt;Desired Output must be a table.&lt;BR /&gt;EMPID	Department&lt;BR /&gt;P9988	HR&lt;BR /&gt;P9988	Finance&lt;BR /&gt;P9988	Analytics&lt;BR /&gt;S3498	HR&lt;BR /&gt;S3498	IT&lt;BR /&gt;S3498	Finance&lt;BR /&gt;R4634	Finance&lt;BR /&gt;R4634	Analytics&lt;BR /&gt;R4634	Sale&lt;BR /&gt;</description>
    <pubDate>Sat, 02 Sep 2017 17:49:39 GMT</pubDate>
    <dc:creator>Purushottam</dc:creator>
    <dc:date>2017-09-02T17:49:39Z</dc:date>
    <item>
      <title>RAW Data import</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/RAW-Data-import/m-p/392729#M5950</link>
      <description>&lt;P&gt;Hello Everyone !&lt;/P&gt;
&lt;P&gt;I want to read this data , but not able ,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;kindly advise me .&lt;/P&gt;
&lt;P&gt;Problem 1&lt;/P&gt;
&lt;P&gt;P9988 HR Finance Analytics S3498 HR IT Finance &lt;BR /&gt;R4634 Finance Analytics Sale &lt;BR /&gt; &lt;BR /&gt;Vocab: EMPID Department &lt;BR /&gt; &lt;BR /&gt;Output Desired &lt;BR /&gt;EMPID Department &lt;BR /&gt;P9988 HR &lt;BR /&gt;P9988 Finance &lt;BR /&gt;P9988 Analytics &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;
&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;
&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;
&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>Sat, 02 Sep 2017 11:28:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/RAW-Data-import/m-p/392729#M5950</guid>
      <dc:creator>Purushottam</dc:creator>
      <dc:date>2017-09-02T11:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: RAW Data import</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/RAW-Data-import/m-p/392754#M5951</link>
      <description>&lt;P&gt;Not exactly sure if I understand what you're trying to do, but the following should at least give you some idea of how you can parse such data:&lt;/P&gt;
&lt;PRE&gt;data have;
  length string $80;
  input;
  string=_infile_;
  cards;
P9988 HR Finance Analytics S3498 HR IT Finance 
R4634 Finance Analytics Sale 
;

data want (keep=empid department);
  set have;
  length substring $80
         empid $5
         department $50;
  retain pattern;
  if _n_ eq 1 then pattern=PRXPARSE("/[a-zA-Z]\d\d\d\d/");
  substring=string;
  do until (start eq 0);
    CALL PRXSUBSTR(pattern, substring, start, length);
    if start gt 0 then do;
      EMPID=substr(substring,start,length);
      substring=substrn(substring,start+length);
      CALL PRXSUBSTR(pattern, substring, start, length);
      if start gt 0 then do;
        Department=substr(substring,1,start-1);
        substring=substrn(substring,start);
      end;
      else Department=substring;
      output;
    end;
  end;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Sep 2017 15:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/RAW-Data-import/m-p/392754#M5951</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-09-02T15:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: RAW Data import</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/RAW-Data-import/m-p/392781#M5952</link>
      <description>Thanks for your Reply,&lt;BR /&gt;But these codes are not working &lt;BR /&gt;Desired Output must be a table.&lt;BR /&gt;EMPID	Department&lt;BR /&gt;P9988	HR&lt;BR /&gt;P9988	Finance&lt;BR /&gt;P9988	Analytics&lt;BR /&gt;S3498	HR&lt;BR /&gt;S3498	IT&lt;BR /&gt;S3498	Finance&lt;BR /&gt;R4634	Finance&lt;BR /&gt;R4634	Analytics&lt;BR /&gt;R4634	Sale&lt;BR /&gt;</description>
      <pubDate>Sat, 02 Sep 2017 17:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/RAW-Data-import/m-p/392781#M5952</guid>
      <dc:creator>Purushottam</dc:creator>
      <dc:date>2017-09-02T17:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: RAW Data import</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/RAW-Data-import/m-p/392784#M5953</link>
      <description>&lt;P&gt;The code I suggested did create a table, but apparently not containing what you want. I think the following does match what you want:&lt;/P&gt;
&lt;PRE&gt;data have;
  length string $80;
  input;
  string=_infile_;
  cards;
P9988 HR Finance Analytics S3498 HR IT Finance 
R4634 Finance Analytics Sale 
;

data want (keep=empid department);
  set have;
  length substring $80
         empid $5
         department full_department $50;
  retain pattern;
  if _n_ eq 1 then pattern=PRXPARSE("/[a-zA-Z]\d\d\d\d/");
  substring=string;
  do until (start eq 0);
    CALL PRXSUBSTR(pattern, substring, start, length);
    if start gt 0 then do;
      EMPID=substr(substring,start,length);
      substring=substrn(substring,start+length);
      CALL PRXSUBSTR(pattern, substring, start, length);
      if start gt 0 then do;
        Full_Department=substr(substring,1,start-1);
        substring=substrn(substring,start);
      end;
      else Full_Department=substring;
      counter=1;
      do while (scan(Full_Department,counter) ne '');
        department=scan(Full_Department,counter);
        counter+1;
        output;
      end;
    end;
  end;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Sep 2017 18:25:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/RAW-Data-import/m-p/392784#M5953</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-09-02T18:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: RAW Data import</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/RAW-Data-import/m-p/392853#M5954</link>
      <description>&lt;PRE&gt;


data have;
input x : $100. @@;
length id $ 100;
retain id;
pid=prxparse('/[a-z]\d+/i');
if prxmatch(pid,strip(x)) then id=x;
 else do;department=x;output;end;
drop pid x;
  cards;
P9988 HR Finance Analytics S3498 HR IT Finance 
R4634 Finance Analytics Sale 
;
run;

&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Sep 2017 10:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/RAW-Data-import/m-p/392853#M5954</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-09-03T10:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: RAW Data import</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/RAW-Data-import/m-p/392863#M5955</link>
      <description>&lt;P&gt;Your post looks garbled. Please post same data using the Insert Code icon on the toolbar in the editor. This will pop-up a new window where you can past the data and/or code and it will preserve the spacing and line breaks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data is in lines then something as simple as this will combine the first word with all of the following words on the line.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  length empid $10 department $20 ;
  infile datalines truncover ;
  input empid department @ ;
  do until (missing(department ));
    output;
    input department @;
  end;
datalines;
P9988 HR Finance Analytics 
S3498 HR IT Finance 
R4634 Finance Analytics Sale 
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is the there are multiple EMPID on the same line then you need some logic to tell an EMPID from a DEPARTMENT name. In you example if looks like they are a letter followed by 4 digits. So something like this should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  length empid $10 department $20 ;
  infile datalines flowover ;
  retain empid ;
  input department @@ ;
  if prxmatch('/^[a-z][0-9]{4}$/i',trim(department)) then empid=department;
  else output;
datalines;
P9988 HR Finance Analytics S3498 HR IT Finance 
R4634 Finance Analytics Sale 
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Sep 2017 16:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/RAW-Data-import/m-p/392863#M5955</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-03T16:36:49Z</dc:date>
    </item>
  </channel>
</rss>

