<?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 index to clean string variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/using-index-to-clean-string-variable/m-p/641126#M191069</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132289"&gt;@Cruise&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Folks:&lt;/P&gt;
&lt;P&gt;I'm trying to use the beginning part of the string variable (i.e., Albany- or Albany(county) or Albany county) until any of these symbols happen as part of the string: '-',&amp;nbsp; ' ' ,&amp;nbsp; '('&lt;/P&gt;
&lt;P&gt;The code below does the job but too inefficient.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to accomplish this in a single step?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You don't say what the desired output is. You don't provide (a portion of) the input data set. We need those things if we're going to help you.&lt;/P&gt;</description>
    <pubDate>Sun, 19 Apr 2020 18:10:41 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-04-19T18:10:41Z</dc:date>
    <item>
      <title>using index to clean string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-index-to-clean-string-variable/m-p/641124#M191068</link>
      <description>&lt;P&gt;Hi Folks:&lt;/P&gt;
&lt;P&gt;I'm trying to use the beginning part of the string variable (i.e., Albany- or Albany(county) or Albany county) until any of these symbols happen as part of the string: '-',&amp;nbsp; ' ' ,&amp;nbsp; '('&lt;/P&gt;
&lt;P&gt;The code below does the job but too inefficient.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to accomplish this in a single step?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TEMP; set census_age1; 
IDNAME1=substr(IDNAME,1,index(IDNAME,'-')-1);
DROP IDNAME; RENAME IDNAME1=IDNAME;   
ID1NAME1=substr(ID1NAME,1,index(ID1NAME,'-')-1);
DROP ID1NAME; RENAME ID1NAME1=ID1NAME; 
RUN;
DATA TEMP1; SET TEMP; 
IDNAME1=substr(IDNAME,1,index(IDNAME,' ')-1);
DROP IDNAME; RENAME IDNAME1=IDNAME;  
RUN;
DATA census_age2; SET TEMP1; 
IDNAME1=substr(IDNAME,1,index(IDNAME,'(')-1);
DROP IDNAME; RENAME IDNAME1=IDNAME; 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 19 Apr 2020 17:56:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-index-to-clean-string-variable/m-p/641124#M191068</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2020-04-19T17:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: using index to clean string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-index-to-clean-string-variable/m-p/641126#M191069</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132289"&gt;@Cruise&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Folks:&lt;/P&gt;
&lt;P&gt;I'm trying to use the beginning part of the string variable (i.e., Albany- or Albany(county) or Albany county) until any of these symbols happen as part of the string: '-',&amp;nbsp; ' ' ,&amp;nbsp; '('&lt;/P&gt;
&lt;P&gt;The code below does the job but too inefficient.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to accomplish this in a single step?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You don't say what the desired output is. You don't provide (a portion of) the input data set. We need those things if we're going to help you.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Apr 2020 18:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-index-to-clean-string-variable/m-p/641126#M191069</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-19T18:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: using index to clean string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-index-to-clean-string-variable/m-p/641140#M191073</link>
      <description>&lt;P&gt;You can try &lt;STRONG&gt;scan&lt;/STRONG&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input idname $20.;
	datalines;
Albany-
Albany(county)
Albany (county)
Albany
;
run;

data want(rename=new_idname=idname);
	set have;
	new_idname=scan(idname, 1, '(- ');
	drop idname;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 19 Apr 2020 18:39:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-index-to-clean-string-variable/m-p/641140#M191073</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2020-04-19T18:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: using index to clean string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-index-to-clean-string-variable/m-p/641143#M191074</link>
      <description>Thanks, solved the problem. Sorry for not providing a mock data. Thanks again!</description>
      <pubDate>Sun, 19 Apr 2020 18:42:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-index-to-clean-string-variable/m-p/641143#M191074</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2020-04-19T18:42:42Z</dc:date>
    </item>
  </channel>
</rss>

