<?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: Using scan function to select a part of variable value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-scan-function-to-select-a-part-of-variable-value/m-p/352575#M82209</link>
    <description>&lt;P&gt;Or if you need to remove all brackets no matter where they are in the string:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
  input test $ 1-70;
  datalines;
Urine Choriogonadotropin Beta (NA)
Urine Choriogonadotropin Beta (NA) something (something else)
;
run;

data two;
  set one;
  /* create variable term1 with the same length as test */
  if _n_=1 then term1=test;
  /* remove everything in brackets from source string */
  term1=prxchange('s/\s*\([^\)]*\)//o',-1,strip(test));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 23 Apr 2017 06:13:52 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2017-04-23T06:13:52Z</dc:date>
    <item>
      <title>Using scan function to select a part of variable value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-scan-function-to-select-a-part-of-variable-value/m-p/352571#M82207</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to have the 'test'value without the charaters in parenthesis. I am using scan function. Is there any better way to get the output. Please suggest. Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output needed:&lt;/P&gt;&lt;P&gt;term1&lt;/P&gt;&lt;P&gt;Urine Choriogonadotropin Beta&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data one;
input test $ 1-35;
datalines;
Urine Choriogonadotropin Beta (NA)
;
run;
data two;
set one;
term1=scan(test,1,'(');
run;&lt;/PRE&gt;</description>
      <pubDate>Sun, 23 Apr 2017 05:38:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-scan-function-to-select-a-part-of-variable-value/m-p/352571#M82207</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-04-23T05:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using scan function to select a part of variable value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-scan-function-to-select-a-part-of-variable-value/m-p/352573#M82208</link>
      <description>&lt;P&gt;Assuming the characters in paranthesis is at the end of the string in all records if present.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; one;&lt;/P&gt;&lt;P&gt;input test $ &lt;STRONG&gt;1&lt;/STRONG&gt;-&lt;STRONG&gt;35&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;Urine Choriogonadotropin Beta (NA)&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; two;&lt;/P&gt;&lt;P&gt;set one;&lt;/P&gt;&lt;P&gt;substr(test,index(test,'('))=' ';&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naveen Srinivasan&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2017 05:55:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-scan-function-to-select-a-part-of-variable-value/m-p/352573#M82208</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-04-23T05:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using scan function to select a part of variable value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-scan-function-to-select-a-part-of-variable-value/m-p/352575#M82209</link>
      <description>&lt;P&gt;Or if you need to remove all brackets no matter where they are in the string:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
  input test $ 1-70;
  datalines;
Urine Choriogonadotropin Beta (NA)
Urine Choriogonadotropin Beta (NA) something (something else)
;
run;

data two;
  set one;
  /* create variable term1 with the same length as test */
  if _n_=1 then term1=test;
  /* remove everything in brackets from source string */
  term1=prxchange('s/\s*\([^\)]*\)//o',-1,strip(test));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 23 Apr 2017 06:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-scan-function-to-select-a-part-of-variable-value/m-p/352575#M82209</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-04-23T06:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using scan function to select a part of variable value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-scan-function-to-select-a-part-of-variable-value/m-p/352597#M82214</link>
      <description>&lt;P&gt;You can do it in one data step. e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data one;
  length test $50;
  input @;
  if index(_infile_,'(') gt 0 then
   _infile_=substr(_infile_,1,index(_infile_,'(')-1);
  input test &amp;amp;;
datalines;
Urine Choriogonadotropin Beta (NA)
Urine Choriogonadotropin Alpha
;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2017 14:39:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-scan-function-to-select-a-part-of-variable-value/m-p/352597#M82214</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-23T14:39:05Z</dc:date>
    </item>
  </channel>
</rss>

