<?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: capture data within brackets into respective column along with alignment in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/537913#M148026</link>
    <description>&lt;P&gt;Thanks Reeza for the guidance.&lt;/P&gt;
&lt;P&gt;As the first format contain information of two columns (&lt;SPAN&gt;[Biscuit] [Sweet]&lt;/SPAN&gt;), I want all word end with 'info' to be the third column renamed with 'tab_info' . It is because the second format always start with 'info' text&amp;nbsp;&lt;SPAN&gt;[Manufacture info] which need to be inserted into tab_info column.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The last column (comment) contain the line starting from hyphen till end . Please check the input file for more example. I am stuck and not able to proceed further&lt;/SPAN&gt;&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, 23 Feb 2019 00:19:52 GMT</pubDate>
    <dc:creator>Abraham</dc:creator>
    <dc:date>2019-02-23T00:19:52Z</dc:date>
    <item>
      <title>capture data within brackets into respective column along with alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/537754#M147945</link>
      <description>&lt;P&gt;Hello Everyone!&lt;/P&gt;
&lt;P&gt;In the attached excel file, I need to split the sentence into line based on semicolon(;) and then capture every word present in square brackets as separate column.&lt;/P&gt;
&lt;P&gt;My input data follow two formats Ifirst one with six enclosed parenthesis and then comment column, second format with two parenthesis and one comment col) which need to be inserted into seven columns to be named like below&lt;/P&gt;
&lt;P&gt;It means all keyword that end with 'info' must align in column number 3 like below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="973"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="973"&gt;[Biscuit] [Sweet] [Product info] [Marigold] [Quality] [Good] - It is made from 'Maida' to 'Suji';&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;[Manufacture info] [Goods It] - Iron sold in very less price&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output&lt;/P&gt;
&lt;TABLE width="644"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="28"&gt;EID&lt;/TD&gt;
&lt;TD width="64"&gt;Prod_info&lt;/TD&gt;
&lt;TD width="64"&gt;Instruct&lt;/TD&gt;
&lt;TD width="104"&gt;Tab_info&lt;/TD&gt;
&lt;TD width="68"&gt;product&lt;/TD&gt;
&lt;TD width="64"&gt;issue&lt;/TD&gt;
&lt;TD width="64"&gt;Rating&lt;/TD&gt;
&lt;TD width="188"&gt;Comment&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;101&lt;/TD&gt;
&lt;TD&gt;Biscuit&lt;/TD&gt;
&lt;TD&gt;Sweet&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Product info&lt;/TD&gt;
&lt;TD&gt;Marigold&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Quality&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Good&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;It is made from 'Maida' to 'Suji'&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;102&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Manufacture info&lt;/TD&gt;
&lt;TD&gt;Goods It&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Iron sold in very less price&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 16:45:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/537754#M147945</guid>
      <dc:creator>Abraham</dc:creator>
      <dc:date>2019-02-22T16:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: capture data within brackets into respective column along with alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/537765#M147953</link>
      <description>&lt;P&gt;COUNTC() to count characters (such as semicolons)&lt;/P&gt;
&lt;P&gt;SCAN() to separate components&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would recommend two do loops, one to partition out each line and the second to partition out each item.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you know where an item maps to what columns? For example with your second ID, and the value "Manufacture Info", it was put under Tab Info column? How did you know to do that? How can we tell the computer to do that?&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40809"&gt;@Abraham&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello Everyone!&lt;/P&gt;
&lt;P&gt;In the attached excel file, I need to split the sentence into line based on semicolon(;) and then capture every word present in square brackets as separate column.&lt;/P&gt;
&lt;P&gt;My input data follow two formats Ifirst one with six enclosed parenthesis and then comment column, second format with two parenthesis and one comment col) which need to be inserted into seven columns to be named like below&lt;/P&gt;
&lt;P&gt;It means all keyword that end with 'info' must align in column number 3 like below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="973"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="973"&gt;[Biscuit] [Sweet] [Product info] [Marigold] [Quality] [Good] - It is made from 'Maida' to 'Suji';&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;[Manufacture info] [Goods It] - Iron sold in very less price&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output&lt;/P&gt;
&lt;TABLE width="644"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="28"&gt;EID&lt;/TD&gt;
&lt;TD width="64"&gt;Prod_info&lt;/TD&gt;
&lt;TD width="64"&gt;Instruct&lt;/TD&gt;
&lt;TD width="104"&gt;Tab_info&lt;/TD&gt;
&lt;TD width="68"&gt;product&lt;/TD&gt;
&lt;TD width="64"&gt;issue&lt;/TD&gt;
&lt;TD width="64"&gt;Rating&lt;/TD&gt;
&lt;TD width="188"&gt;Comment&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;101&lt;/TD&gt;
&lt;TD&gt;Biscuit&lt;/TD&gt;
&lt;TD&gt;Sweet&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Product info&lt;/TD&gt;
&lt;TD&gt;Marigold&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Quality&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Good&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;It is made from 'Maida' to 'Suji'&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;102&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Manufacture info&lt;/TD&gt;
&lt;TD&gt;Goods It&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Iron sold in very less price&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 17:05:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/537765#M147953</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-22T17:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: capture data within brackets into respective column along with alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/537913#M148026</link>
      <description>&lt;P&gt;Thanks Reeza for the guidance.&lt;/P&gt;
&lt;P&gt;As the first format contain information of two columns (&lt;SPAN&gt;[Biscuit] [Sweet]&lt;/SPAN&gt;), I want all word end with 'info' to be the third column renamed with 'tab_info' . It is because the second format always start with 'info' text&amp;nbsp;&lt;SPAN&gt;[Manufacture info] which need to be inserted into tab_info column.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The last column (comment) contain the line starting from hyphen till end . Please check the input file for more example. I am stuck and not able to proceed further&lt;/SPAN&gt;&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, 23 Feb 2019 00:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/537913#M148026</guid>
      <dc:creator>Abraham</dc:creator>
      <dc:date>2019-02-23T00:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: capture data within brackets into respective column along with alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/537923#M148032</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40809"&gt;@Abraham&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below code will only work if you've always got a bracket with an "info" word in it AND this bracket can always get mapped to output column Tab_Info. If that's not the case then the code below will likely generate array out of range errors and the like.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample(drop=_:);
  length empid $5 _string $200;
  array nodes {6} $20. Prod_info Instruct Tab_info product issue Rating;
  length Comments $80;
  call missing(of _all_);

  infile datalines truncover dlm='|;';
  input Empid:$10. @;

  do while(1);
    input _string:$200. @;
    if missing(_string) then leave;

    _n_nodes=countc(_string,'[');
    /* find node with keyword "info" */
    do _i=1 to 2*_n_nodes by 2;
      if findw(scan(_string,_i,'[]'),'info',' ','i')&amp;gt;0 then 
        do;
          _info_node=(_i+1)/2;
          leave;
        end;
    end;

    /* populate node variables */
    do _i=1 to 2*_n_nodes by 2;
      nodes[(_i+1)/2 + (3-_info_node)]=scan(_string,_i,'[]');
    end;
    /* populate comments */
    comments=substrn(_string,findc(_string,'-')+1);
  end;

  input;

  datalines4;
101|[Biscuit] [Sweet] [Product info] [Marigold] [Quality] [Good] - It is made from 'Maida' to 'Suji'; 
102|[Manufacture info] [Goods It] - Iron sold in very less price
103|[Soap] [Tless] [ABX Info] [Lux] [SVD] [Moisturiser] - Smoothening skin
104|[ITEM] [Content] [Goods info] [Sugar] [chs] [Good] - excess cause diabetes
105|[Biscuit] [Sweet] [Product info] [Marigold] [Quality] [Good] - It is made from 'Maida' to 'Suji'; [ITEM1] [Content2] [Goods21 info] [Jaggery] [chs] [Medic] - Healthier;
106|[Cust info] [Employee] - 300 resigned today
107|[QUERY] [Dept info] [ISSUE] [Quality] [NO IDEA] - Decide your "salary"; 
;;;;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Feb 2019 01:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/537923#M148032</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-02-23T01:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: capture data within brackets into respective column along with alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/538186#M148142</link>
      <description>&lt;P&gt;Thank you very much Partrick for your time and work on my query.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was working on the program but did not find the expected output. If you check EID 105 , I need two records to be displayed as every ID contain two records separated by semicolon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The program should split into number of lines based on semicolon and then store all data in a table format. Please have a look into the attachment where you can check the expected output sheet .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="644"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="28"&gt;105&lt;/TD&gt;
&lt;TD width="64"&gt;Chocolate&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;Sweet&amp;nbsp;&lt;/TD&gt;
&lt;TD width="104"&gt;Product info&lt;/TD&gt;
&lt;TD width="68"&gt;Cadburry&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;Quality&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;Good&amp;nbsp;&lt;/TD&gt;
&lt;TD width="188"&gt;It is made from cococa seeds&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;105&lt;/TD&gt;
&lt;TD&gt;ITEM1&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Content2&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Goods21 info&lt;/TD&gt;
&lt;TD&gt;Jaggery&lt;/TD&gt;
&lt;TD&gt;chs&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Medic&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Healthier&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 05:18:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/538186#M148142</guid>
      <dc:creator>Abraham</dc:creator>
      <dc:date>2019-02-25T05:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: capture data within brackets into respective column along with alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/538191#M148143</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40809"&gt;@Abraham&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ooops... that was a last second change which I didn't test anymore.&lt;/P&gt;
&lt;P&gt;All you need to do is add an OUTPUT statement at the end of the loop and things should work.&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp; comments=substrn(_string,findc(_string,'-')+1);&lt;BR /&gt;&amp;nbsp; &lt;FONT color="#FF0000"&gt;output;&lt;/FONT&gt;&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below the fixed code version.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample(drop=_:);
  length empid $5 _string $200;
  array nodes {6} $20. Prod_info Instruct Tab_info product issue Rating;
  length Comments $80;
  call missing(of _all_);

  infile datalines truncover dlm='|;';
  input Empid:$10. @;

  do while(1);
    input _string:$200. @;
    if missing(_string) then leave;

    _n_nodes=countc(_string,'[');
    /* find node with keyword "info" */
    do _i=1 to 2*_n_nodes by 2;
      if findw(scan(_string,_i,'[]'),'info',' ','i')&amp;gt;0 then 
        do;
          _info_node=(_i+1)/2;
          leave;
        end;
    end;

    /* populate node variables */
    do _i=1 to 2*_n_nodes by 2;
      nodes[(_i+1)/2 + (3-_info_node)]=scan(_string,_i,'[]');
    end;
    /* populate comments */
    comments=substrn(_string,findc(_string,'-')+1);
    output;
  end;

  input;

  datalines4;
101|[Biscuit] [Sweet] [Product info] [Marigold] [Quality] [Good] - It is made from 'Maida' to 'Suji'; 
102|[Manufacture info] [Goods It] - Iron sold in very less price
103|[Soap] [Tless] [ABX Info] [Lux] [SVD] [Moisturiser] - Smoothening skin
104|[ITEM] [Content] [Goods info] [Sugar] [chs] [Good] - excess cause diabetes
105|[Biscuit] [Sweet] [Product info] [Marigold] [Quality] [Good] - It is made from 'Maida' to 'Suji'; [ITEM1] [Content2] [Goods21 info] [Jaggery] [chs] [Medic] - Healthier;
106|[Cust info] [Employee] - 300 resigned today
107|[QUERY] [Dept info] [ISSUE] [Quality] [NO IDEA] - Decide your "salary"; 
;;;;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Feb 2019 06:11:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/538191#M148143</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-02-25T06:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: capture data within brackets into respective column along with alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/538723#M148304</link>
      <description>&lt;P&gt;Thank you Patrick once again for your great help. Your program is amazing. Its working perfectly now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As&amp;nbsp; I am new comer to SAS, if possible, can you please guide how to insert the same program if I use proc import to pull the input file directly like below. I use it like below but I am missing somewhere.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks once again for your extreme support&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc import datafile="/proj/sastmp/pvdm/01_QC/specialchar.csv"
     out=test_output
     dbms=csv
     replace;
     getnames=yes;	 
	 guessingrows=32767;
run;

data testing1;
length empid $5 _string $200;
length Comments $80;
set test_output;
array nodes {6} $20. Prod_info Instruct Tab_info product issue Rating;
do while(1);
    input _string:$200. @;
    if missing(_string) then leave;

    _n_nodes=countc(_string,'[');
    /* find node with keyword "info" */
    do _i=1 to 2*_n_nodes by 2;
      if findw(scan(_string,_i,'[]'),'info',' ','i')&amp;gt;0 then 
        do;
          _info_node=(_i+1)/2;
          leave;
        end;
    end;

    /* populate node variables */
    do _i=1 to 2*_n_nodes by 2;
      nodes[(_i+1)/2 + (3-_info_node)]=scan(_string,_i,'[]');
    end;
    /* populate comments */
    comments=substrn(_string,findc(_string,'-')+1);
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Feb 2019 17:18:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/538723#M148304</guid>
      <dc:creator>Abraham</dc:creator>
      <dc:date>2019-02-26T17:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: capture data within brackets into respective column along with alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/538796#M148344</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40809"&gt;@Abraham&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't use Proc Import here but an INFILE/INPUT statement as this gives you much more control over reading the data. In doing so almost no code changes are required. You just need to point to the external .csv and define appropriate delimiting characters - i.e. dlm=',;'&lt;/P&gt;
&lt;PRE&gt;  infile "/proj/sastmp/pvdm/01_QC/specialchar.csv" truncover dlm='|;';
  input Empid:$10. @;&lt;/PRE&gt;
&lt;P&gt;If your .csv contains more then two columns AND the "_string" is not the last column then please share a few lines of the actual .csv structure (as attachment) if you need help.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 20:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/538796#M148344</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-02-26T20:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: capture data within brackets into respective column along with alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/538855#M148372</link>
      <description>&lt;P&gt;Thanks Patrick.&lt;/P&gt;
&lt;P&gt;My CSV file contain two columns only, attachment for your reference.&lt;/P&gt;
&lt;P&gt;The code is not working. I change the infile path and input statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample(drop=_:);
  length empid $5 _string $200;
  array nodes {6} $20. Prod_info Instruct Tab_info product issue Rating;
  length Comments $80;
  call missing(of _all_);
  infile "/Saquee/final/specialchar.csv" truncover dlm='|;';
  input Empid:$10. @;
  do while(1);
    input _string:$200. @;
    if missing(_string) then leave;

    _n_nodes=countc(_string,'[');
    /* find node with keyword "info" */
    do _i=1 to 2*_n_nodes by 2;
      if findw(scan(_string,_i,'[]'),'info',' ','i')&amp;gt;0 then 
        do;
          _info_node=(_i+1)/2;
          leave;
        end;
    end;

    /* populate node variables */
    do _i=1 to 2*_n_nodes by 2;
      nodes[(_i+1)/2 + (3-_info_node)]=scan(_string,_i,'[]');
    end;
    /* populate comments */
    comments=substrn(_string,findc(_string,'-')+1);
    output;
  end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;he code is not working. I think there is an issue with import file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 00:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/538855#M148372</guid>
      <dc:creator>Abraham</dc:creator>
      <dc:date>2019-02-27T00:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: capture data within brackets into respective column along with alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/538896#M148402</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/40809"&gt;@Abraham&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below code works in my SAS Windows environment:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample(drop=_:);
  length empid $5 _string $200;
  array nodes {6} $20. Prod_info Instruct Tab_info product issue Rating;
  length Comments $80;
  call missing(of _all_);
  infile "c:\temp\specialchar.csv" truncover dlm=',;' firstobs=2 termstr=crlf lrecl=1000;
  input Empid:$10. @;
  do while(1);
    input _string:$200. @;
    if missing(_string) then leave;

    /* remove enclosing double quotes if any */
    _string=prxchange('s/^"(.*)"$/\1/',1,strip(_string));

    _n_nodes=countc(_string,'[');
    /* find node with keyword "info" */
    do _i=1 to 2*_n_nodes by 2;
      if findw(scan(_string,_i,'[]'),'info',' ','i')&amp;gt;0 then 
        do;
          _info_node=(_i+1)/2;
          leave;
        end;
    end;

    /* populate node variables */
    do _i=1 to 2*_n_nodes by 2;
      nodes[(_i+1)/2 + (3-_info_node)]=scan(_string,_i,'[]');
    end;
    /* populate comments */
    comments=substrn(_string,findc(_string,'-')+1);
    output;
  end;

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There are three things which might have caused issues for you:&lt;/P&gt;
&lt;P&gt;1. The double quotes around the source string. That's something I didn't code for. I've now added logic for this (the PRXCHANGE() bit)&lt;/P&gt;
&lt;PRE&gt;"[HR] [QUERY] [Dept info] [ISSUE] [Quality] [NO IDEA] - Decide your ""salary"";&lt;/PRE&gt;
&lt;P&gt;2. Your data starts on the 2nd row only. I've added FIRSTOBS=2 to the infile statement to deal with this.&lt;/P&gt;
&lt;P&gt;3. Not sure if this just happened when transferring your .csv to my environment or if this is in your actual data. What I've got is CRLF as line delimiter.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27520i77C1BEFC049A031B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The path you're using indicates that your OS is Unix/Linux. There the default line delimiter is LF only. I've added TERMSTR=crlf to the infile statement to deal with this. Remove it in case your actual file only uses LF.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 07:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/538896#M148402</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-02-27T07:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: capture data within brackets into respective column along with alignment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/538922#M148412</link>
      <description>&lt;P&gt;Perfet Patick. Thanks once again for your time in looking into my issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If possible, check that I am getting one duplicate records with quote in the last row which is not required. Based on your suggestion, I will convert all double quote ("") with ("""")&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="duplicate.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27525iA17B34FE02167A83/image-size/large?v=v2&amp;amp;px=999" role="button" title="duplicate.jpg" alt="duplicate.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks once again&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 10:38:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/capture-data-within-brackets-into-respective-column-along-with/m-p/538922#M148412</guid>
      <dc:creator>Abraham</dc:creator>
      <dc:date>2019-02-27T10:38:29Z</dc:date>
    </item>
  </channel>
</rss>

