<?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: Scanning characters in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875714#M82732</link>
    <description>&lt;P&gt;You can use backslash to "escape" the next character.&amp;nbsp; So if you have a character in your pattern that happens to be an special character to RegEx just prefic it with a backslash.&lt;/P&gt;
&lt;P&gt;So in your example it is the / that is causing trouble.&lt;/P&gt;
&lt;P&gt;So fix it like this:&lt;/P&gt;
&lt;PRE&gt;"/(DEMENTIA|ALZH|DEMENTIA|DEMENTIA - ALZH|DEMETIA|DEMENI|DEMENTAI|H\/O DEMENETIA)/i"&lt;/PRE&gt;</description>
    <pubDate>Mon, 15 May 2023 02:41:44 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-05-15T02:41:44Z</dc:date>
    <item>
      <title>Scanning characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/872063#M82664</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;How can I extract part of a character variable including the delimiter ("_")? For example I want to extract "MyGroup_" from the value "MyGroup_152".&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 22:58:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/872063#M82664</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-04-25T22:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/872064#M82665</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Want;
  String = 'MyGroup_152';
  SubString = substr(String, 1, find(String,'_'));
  put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Apr 2023 23:14:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/872064#M82665</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-04-25T23:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/872067#M82666</link>
      <description>&lt;P&gt;Thanks very much. It worked. I don't need the&lt;/P&gt;&lt;PRE class=""&gt;&lt;CODE&gt;put _all_;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Apr 2023 23:34:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/872067#M82666</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-04-25T23:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/872068#M82667</link>
      <description>&lt;P&gt;PUT _ALL_ is just to see the results in the log&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 23:40:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/872068#M82667</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-04-25T23:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/872070#M82668</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/108705"&gt;@bayzid&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will find all occurances&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	x='MyGroup_152 YourGroup_1230 pref_OurGroup_232';
	start=1;
	stop=length(x);
	pattern_id=prxparse('/[a-zA-Z]+_/i');
	call prxnext(pattern_id, start, stop, x, position, length);
	do while(position&amp;gt;0);
		str=substr(x, position, length);
		call prxnext(pattern_id, start, stop, x, position, length);
		put str=;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Apr 2023 23:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/872070#M82668</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2023-04-25T23:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875538#M82724</link>
      <description>&lt;P&gt;How can i extract a keyword from a list of words in a variable? For examples, if the variable x ='MyGroup_152 YourGroup_1230 pref_OurGroup_232' I want to extract either of "MyGroup", "Your" and "Our", whichever appears first and save into a different variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 22:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875538#M82724</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-05-12T22:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875609#M82725</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/108705"&gt;@bayzid&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this what you are looking for?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(KEEP=x my our your);
	x='YourGroup_1230 pref_OurGroup_232 MyGroup_152';
	array words {3} 3 my your our;
	pattern_id=prxparse('/(My|Your|Our)/i');
	start=1;
	stop=length(x);
	call prxnext(pattern_id, start, stop, x, position, length);
	do while(position&amp;gt;0);
		str=substr(x, position, length);
		call prxnext(pattern_id, start, stop, x, position, length);
		put str=;
		found=0;
		do v=1 to dim(words) until(found);
			if ( lowcase(str) = lowcase(vname(words[v])) ) then
			do;
				found=1;
				words[v]=1;
			end;
		end;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 May 2023 19:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875609#M82725</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2023-05-13T19:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875612#M82726</link>
      <description>&lt;P&gt;I have variable x in my dataset and want to create extract as below.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BayzidurRahman_0-1684011860784.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83947iA4EA22563679C4A6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BayzidurRahman_0-1684011860784.png" alt="BayzidurRahman_0-1684011860784.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 May 2023 21:04:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875612#M82726</guid>
      <dc:creator>BayzidurRahman</dc:creator>
      <dc:date>2023-05-13T21:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875613#M82727</link>
      <description>&lt;P&gt;this should do it&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(KEEP=x extract);
	x='YourGroup_1230 pref_OurGroup_232 MyGroup_152';
	array words {3} 3 my your our;
	pattern_id=prxparse('/(My|Your|Our)/i');
	start=1;
	stop=length(x);
	call prxnext(pattern_id, start, stop, x, position, length);
	if (position&amp;gt;0)then
		extract=substr(x, position, length);

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 May 2023 21:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875613#M82727</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2023-05-13T21:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875620#M82728</link>
      <description>&lt;P&gt;Thanks. My situation is a little bit more complicated. The key words i want to extract can have spaces but not be a part of another bigger word and it can end with a dot or comma.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BayzidurRahman_0-1684019551382.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83948i358616B3E2A16A65/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BayzidurRahman_0-1684019551382.png" alt="BayzidurRahman_0-1684019551382.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 May 2023 23:12:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875620#M82728</guid>
      <dc:creator>BayzidurRahman</dc:creator>
      <dc:date>2023-05-13T23:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875621#M82729</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/437116"&gt;@BayzidurRahman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We can only go by the sample of data you provided in your post.&lt;/P&gt;
&lt;P&gt;In all cases, We have provided you with multiple ways to search and extract the words you are looking for. Now it's your turn to read the docs and extend/customize any of these solution to fit your needs. Otherwise you'll never learn and expand your skills sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Sat, 13 May 2023 23:32:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875621#M82729</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2023-05-13T23:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875623#M82730</link>
      <description>&lt;P&gt;No problem. I have sorted it out. I got rid of the array statement as it was returning error message for large number words.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data ht (keep=ResidentId Fac_id Diagnosis caps ht Hypertension htc);
	set ehr;
			caps = compbl(tranwrd(caps, ",", " ,"));
			caps = compbl(tranwrd(caps, ".", " ."));
			caps = compbl(tranwrd(caps, ";", " ;"));
				caps='     '||caps;
  	pattern_id=prxparse('/( HTN| HT| HYPTENSION| HIGH BP| HIGH BLOOD P| HBP| HYPERTENSION)/i');
	start=1;
	stop=length(caps);
	call prxnext(pattern_id, start, stop, caps, position, length);
	if (position&amp;gt;0)then
		htc=substr(caps, position, length);
ht=(htc ne "");
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 May 2023 01:09:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875623#M82730</guid>
      <dc:creator>BayzidurRahman</dc:creator>
      <dc:date>2023-05-14T01:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875706#M82731</link>
      <description>&lt;P&gt;Some of the key words contain hyphen and backslash which returns error message.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;pattern_id=prxparse('/(DEMENTIA|ALZH|DEMENTIA|DEMENTIA - ALZH|DEMETIA|DEMENI|DEMENTAI|H/O DEMENETIA)/i');


ERROR: Invalid characters "DEMENETIA)/i" after end delimiter "/" of regular expression
       "/(DEMENTIA|ALZH|DEMENTIA|DEMENTIA - ALZH|DEMETIA|DEMENI|DEMENTAI|H/O DEMENETIA)/i".
ERROR: The regular expression passed to the function PRXPARSE contains a syntax error.
NOTE: Argument 1 to function PRXPARSE('/(DEMENTIA|A'[12 of 81 characters shown]) at line 24703
      column 13 is invalid.
NOTE: Argument 1 to the function PRXNEXT is missing.
ERROR: Argument 1 to the function PRXNEXT must be a positive integer returned by PRXPARSE for
       a valid pattern.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there any way to get around this problem?&lt;/P&gt;</description>
      <pubDate>Sun, 14 May 2023 22:24:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875706#M82731</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-05-14T22:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875714#M82732</link>
      <description>&lt;P&gt;You can use backslash to "escape" the next character.&amp;nbsp; So if you have a character in your pattern that happens to be an special character to RegEx just prefic it with a backslash.&lt;/P&gt;
&lt;P&gt;So in your example it is the / that is causing trouble.&lt;/P&gt;
&lt;P&gt;So fix it like this:&lt;/P&gt;
&lt;PRE&gt;"/(DEMENTIA|ALZH|DEMENTIA|DEMENTIA - ALZH|DEMETIA|DEMENI|DEMENTAI|H\/O DEMENETIA)/i"&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 May 2023 02:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875714#M82732</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-15T02:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning characters</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875742#M82733</link>
      <description>&lt;P&gt;Thanks. That worked.&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 06:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scanning-characters/m-p/875742#M82733</guid>
      <dc:creator>bayzid</dc:creator>
      <dc:date>2023-05-15T06:46:34Z</dc:date>
    </item>
  </channel>
</rss>

