<?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: separate value between special characters under a single variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/separate-value-between-special-characters-under-a-single/m-p/708924#M217899</link>
    <description>Thank you so much!</description>
    <pubDate>Thu, 31 Dec 2020 17:43:54 GMT</pubDate>
    <dc:creator>chinna0369</dc:creator>
    <dc:date>2020-12-31T17:43:54Z</dc:date>
    <item>
      <title>separate value between special characters under a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/separate-value-between-special-characters-under-a-single/m-p/708910#M217891</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have variable values like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RIGHT LYMPH NODE; RIGHT EXTERNAL LYMPH; LEFT LYMPH NODE&lt;/P&gt;&lt;P&gt;RIGHT HAND; LEFT LEG&lt;/P&gt;&lt;P&gt;HEART&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create a new variable like below:&lt;/P&gt;&lt;P&gt;HEART&lt;/P&gt;&lt;P&gt;LEFT LEG&lt;/P&gt;&lt;P&gt;LEFT LYMPH NODE&lt;/P&gt;&lt;P&gt;RIGHT EXTERNAL LYMPH&lt;/P&gt;&lt;P&gt;RIGHT HAND&lt;/P&gt;&lt;P&gt;RIGHT LYMPH NODE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which means:&lt;/P&gt;&lt;P&gt;1. separate values between special characters&lt;/P&gt;&lt;P&gt;2. Create a new variable in alphabetical order with those separated values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Nyalamadugu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Dec 2020 16:58:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/separate-value-between-special-characters-under-a-single/m-p/708910#M217891</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2020-12-31T16:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: separate value between special characters under a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/separate-value-between-special-characters-under-a-single/m-p/708918#M217895</link>
      <description>&lt;P&gt;Use the SCAN() function to parse the strings at the semi-colons.&amp;nbsp; Output each value as a separate observation.&amp;nbsp; Then sort.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  row+1;
  input string $80.;
cards4;
RIGHT LYMPH NODE; RIGHT EXTERNAL LYMPH; LEFT LYMPH NODE
RIGHT HAND; LEFT LEG
HEART
;;;;

data want;
  set have;
  do index=1 to countw(string,';');
     word=strip(scan(string,index,';'));
     output;
  end;
run;

proc sort;
  by word;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;Obs   row   string                                                    index   word

 1     3    HEART                                                       1     HEART
 2     2    RIGHT HAND; LEFT LEG                                        2     LEFT LEG
 3     1    RIGHT LYMPH NODE; RIGHT EXTERNAL LYMPH; LEFT LYMPH NODE     3     LEFT LYMPH NODE
 4     1    RIGHT LYMPH NODE; RIGHT EXTERNAL LYMPH; LEFT LYMPH NODE     2     RIGHT EXTERNAL LYMPH
 5     2    RIGHT HAND; LEFT LEG                                        1     RIGHT HAND
 6     1    RIGHT LYMPH NODE; RIGHT EXTERNAL LYMPH; LEFT LYMPH NODE     1     RIGHT LYMPH NODE&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Dec 2020 17:30:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/separate-value-between-special-characters-under-a-single/m-p/708918#M217895</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-12-31T17:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: separate value between special characters under a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/separate-value-between-special-characters-under-a-single/m-p/708924#M217899</link>
      <description>Thank you so much!</description>
      <pubDate>Thu, 31 Dec 2020 17:43:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/separate-value-between-special-characters-under-a-single/m-p/708924#M217899</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2020-12-31T17:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: separate value between special characters under a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/separate-value-between-special-characters-under-a-single/m-p/714659#M220654</link>
      <description>Missed a feature of INFILE which would simplify the task.&lt;BR /&gt;INFILE statement option DLM=';' ensures the input statement parses to semi colons or end-of-line. &lt;BR /&gt;Trailing @@ on INPUT statement preserves the buffer until exhausted.&lt;BR /&gt;Data ; &lt;BR /&gt;Infile cards dlm= ';' truncover ;&lt;BR /&gt;Input objectname :$50. @@ ;&lt;BR /&gt;Cards4;&lt;BR /&gt;Those data lines&lt;BR /&gt;;;;;&lt;BR /&gt;Proc sort out= wanted ;&lt;BR /&gt;By objectname ;&lt;BR /&gt;Run;</description>
      <pubDate>Wed, 27 Jan 2021 16:42:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/separate-value-between-special-characters-under-a-single/m-p/714659#M220654</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2021-01-27T16:42:22Z</dc:date>
    </item>
  </channel>
</rss>

