<?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 Extract and split variables in multiple parentheses in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Extract-and-split-variables-in-multiple-parentheses/m-p/725082#M19844</link>
    <description>&lt;P&gt;Hi SAS forum,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have strings are like this:&lt;/P&gt;&lt;P&gt;Heart failure, unspecified (I50.9) Osteomyelitis, unspecified (M86.9) Cardiogenic shock (R57.0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to divide the strings into different variables according to the parentheses.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I saw a similar question:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Data-Management/splitting-a-variable-into-several-depending-on-parenthesis/td-p/209649" target="_blank"&gt;https://communities.sas.com/t5/SAS-Data-Management/splitting-a-variable-into-several-depending-on-parenthesis/td-p/209649&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and modified the code as follow:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;infile cards dsd;&lt;BR /&gt;length name $100.;&lt;BR /&gt;input name $;&lt;BR /&gt;cards;&lt;BR /&gt;"Heart failure, unspecified (I50.9) Osteomyelitis, unspecified (M86.9) Cardiogenic shock (R57.0)"&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;DIAGNOSIS1 = scan(name,1,'(,)');&lt;BR /&gt;DIAGNOSISCODE1 = scan(name,2,'(,)');&lt;BR /&gt;DIAGNOSIS2 = scan(name,3,'(,)');&lt;BR /&gt;DIAGNOSISCODE2 = scan(name,4,'(,)');&lt;BR /&gt;DIAGNOSIS3 = scan(name,5,'(,)');&lt;BR /&gt;DIAGNOSISCODE3 = scan(name,6,'(,)');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But It seems I should remove the comma in the&amp;nbsp;parentheses to get the desired results, like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;DIAGNOSIS1 = scan(name,1,'()');&lt;BR /&gt;DIAGNOSISCODE1 = scan(name,2,'()');&lt;BR /&gt;DIAGNOSIS2 = scan(name,3,'()');&lt;BR /&gt;DIAGNOSISCODE2 = scan(name,4,'()');&lt;BR /&gt;DIAGNOSIS3 = scan(name,5,'()');&lt;BR /&gt;DIAGNOSISCODE3 = scan(name,6,'()');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have 2 questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. What's the difference between these 2 codes:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;DIAGNOSIS1 = scan(name,1,'&lt;FONT color="#FF0000"&gt;(,)&lt;/FONT&gt;');&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;DIAGNOSIS1 = scan(name,1,'&lt;FONT color="#FF0000"&gt;()&lt;/FONT&gt;');&lt;/P&gt;&lt;P&gt;&amp;nbsp; (with/without the comma inside the&amp;nbsp;parentheses?)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Some of my data contains&amp;nbsp;Chinese characters and fullwidth comma (，) and they are not in the&amp;nbsp;parentheses. Would it be okay to deal with the data with the same code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
    <pubDate>Wed, 10 Mar 2021 09:32:55 GMT</pubDate>
    <dc:creator>sylvia106</dc:creator>
    <dc:date>2021-03-10T09:32:55Z</dc:date>
    <item>
      <title>Extract and split variables in multiple parentheses</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Extract-and-split-variables-in-multiple-parentheses/m-p/725082#M19844</link>
      <description>&lt;P&gt;Hi SAS forum,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have strings are like this:&lt;/P&gt;&lt;P&gt;Heart failure, unspecified (I50.9) Osteomyelitis, unspecified (M86.9) Cardiogenic shock (R57.0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to divide the strings into different variables according to the parentheses.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I saw a similar question:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Data-Management/splitting-a-variable-into-several-depending-on-parenthesis/td-p/209649" target="_blank"&gt;https://communities.sas.com/t5/SAS-Data-Management/splitting-a-variable-into-several-depending-on-parenthesis/td-p/209649&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and modified the code as follow:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;infile cards dsd;&lt;BR /&gt;length name $100.;&lt;BR /&gt;input name $;&lt;BR /&gt;cards;&lt;BR /&gt;"Heart failure, unspecified (I50.9) Osteomyelitis, unspecified (M86.9) Cardiogenic shock (R57.0)"&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;DIAGNOSIS1 = scan(name,1,'(,)');&lt;BR /&gt;DIAGNOSISCODE1 = scan(name,2,'(,)');&lt;BR /&gt;DIAGNOSIS2 = scan(name,3,'(,)');&lt;BR /&gt;DIAGNOSISCODE2 = scan(name,4,'(,)');&lt;BR /&gt;DIAGNOSIS3 = scan(name,5,'(,)');&lt;BR /&gt;DIAGNOSISCODE3 = scan(name,6,'(,)');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But It seems I should remove the comma in the&amp;nbsp;parentheses to get the desired results, like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;DIAGNOSIS1 = scan(name,1,'()');&lt;BR /&gt;DIAGNOSISCODE1 = scan(name,2,'()');&lt;BR /&gt;DIAGNOSIS2 = scan(name,3,'()');&lt;BR /&gt;DIAGNOSISCODE2 = scan(name,4,'()');&lt;BR /&gt;DIAGNOSIS3 = scan(name,5,'()');&lt;BR /&gt;DIAGNOSISCODE3 = scan(name,6,'()');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have 2 questions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. What's the difference between these 2 codes:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;DIAGNOSIS1 = scan(name,1,'&lt;FONT color="#FF0000"&gt;(,)&lt;/FONT&gt;');&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;DIAGNOSIS1 = scan(name,1,'&lt;FONT color="#FF0000"&gt;()&lt;/FONT&gt;');&lt;/P&gt;&lt;P&gt;&amp;nbsp; (with/without the comma inside the&amp;nbsp;parentheses?)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Some of my data contains&amp;nbsp;Chinese characters and fullwidth comma (，) and they are not in the&amp;nbsp;parentheses. Would it be okay to deal with the data with the same code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Mar 2021 09:32:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Extract-and-split-variables-in-multiple-parentheses/m-p/725082#M19844</guid>
      <dc:creator>sylvia106</dc:creator>
      <dc:date>2021-03-10T09:32:55Z</dc:date>
    </item>
    <item>
      <title>Re: Extract and split variables in multiple parentheses</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Extract-and-split-variables-in-multiple-parentheses/m-p/725085#M19845</link>
      <description>&lt;P&gt;Use nested SCAN functions:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
length extract $10;
do i = 2 to countw(name,"(");
  extract = scan(scan(name,i,"("),1,")");
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Mar 2021 09:45:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Extract-and-split-variables-in-multiple-parentheses/m-p/725085#M19845</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-10T09:45:25Z</dc:date>
    </item>
  </channel>
</rss>

