<?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 How to remove specific character from a string value. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959789#M374446</link>
    <description>&lt;P&gt;While Import excel file using Proc Import for few subject# ID I am getting some&amp;nbsp;specific character value. Example below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;3-158-021"&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp;Expecting Subject id should be:&amp;nbsp;3-158-021 (9 characters)&lt;/P&gt;&lt;P&gt;The below SAS code I have used however, it is not working. any help would be appreciated.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data Keosys_vdr2;
	length SubjectNumber $150;
	set Keosys_vdr1 (firstobs=2);
	subjectnumber=strip(compress(Subject,'"'));
	*subjectnumber1=prxchange('s/\"//',-1,subjectnumber);
	keep SiteNumber subjectnumber subjectnumber1 Current_Status;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 20 Feb 2025 15:43:49 GMT</pubDate>
    <dc:creator>PC7</dc:creator>
    <dc:date>2025-02-20T15:43:49Z</dc:date>
    <item>
      <title>How to remove specific character from a string value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959789#M374446</link>
      <description>&lt;P&gt;While Import excel file using Proc Import for few subject# ID I am getting some&amp;nbsp;specific character value. Example below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;3-158-021"&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp;Expecting Subject id should be:&amp;nbsp;3-158-021 (9 characters)&lt;/P&gt;&lt;P&gt;The below SAS code I have used however, it is not working. any help would be appreciated.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data Keosys_vdr2;
	length SubjectNumber $150;
	set Keosys_vdr1 (firstobs=2);
	subjectnumber=strip(compress(Subject,'"'));
	*subjectnumber1=prxchange('s/\"//',-1,subjectnumber);
	keep SiteNumber subjectnumber subjectnumber1 Current_Status;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Feb 2025 15:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959789#M374446</guid>
      <dc:creator>PC7</dc:creator>
      <dc:date>2025-02-20T15:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove specific character from a string value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959791#M374447</link>
      <description>&lt;P&gt;It's not really clear to me what the data actually is here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;3-158-021"&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is there a carriage return/end of line character in your data?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This works for me&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    subject='"
3-158-021" ';
    want = compress(subject,'"');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;From now on, please help us help you. Please don't say "it is not working" and provide no other information. Please, from now on, do provide the incorrect results that you are getting or the log with errors in it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 16:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959791#M374447</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-02-20T16:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove specific character from a string value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959797#M374448</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/472110"&gt;@PC7&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe it's easier to specify the characters to be &lt;EM&gt;kept&lt;/EM&gt; in the subject ID, e.g., digits and hyphens (cf. the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n0fcshr0ir3h73n1b845c4aq58hz.htm" target="_blank" rel="noopener"&gt;COMPRESS function documentation&lt;/A&gt;)&lt;FONT face="arial,helvetica,sans-serif"&gt;:&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;subjectnumber=compress(Subject,&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;'-','kd'&lt;/STRONG&gt;&lt;/FONT&gt;);&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;Or display one of the strings in $HEX. format to find out exactly what characters need to be removed. Here's an example where those double quotes are in fact &lt;EM&gt;curly&lt;/EM&gt; quotes:&lt;/P&gt;
&lt;PRE&gt;data _null_;
Subject='&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;“&lt;/STRONG&gt;&lt;/FONT&gt;3-158-021&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;”&lt;/STRONG&gt;&lt;/FONT&gt;';
put Subject $hex.;
run;&lt;/PRE&gt;
&lt;P&gt;Result in the log:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;93&lt;/STRONG&gt;&lt;/FONT&gt;332D3135382D303231&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;94&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;So this would remove them:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;subjectnumber=compress(Subject,&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;'9394'x&lt;/FONT&gt;&lt;/STRONG&gt;);&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 16:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959797#M374448</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-02-20T16:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove specific character from a string value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959808#M374451</link>
      <description>&lt;P&gt;Excellent idea,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 18:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959808#M374451</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-02-20T18:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove specific character from a string value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959825#M374455</link>
      <description>&lt;P&gt;If your compress function call&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;subjectnumber=strip(compress(Subject,'"'));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;does not remove the character, then you specified the wrong character in the call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So look at what character is actually in your data.&amp;nbsp; Display it using the $HEX format.&amp;nbsp; Once you find out what character it is then use a hex literal in the code.&amp;nbsp; If you are running with ENCODING=UTF-8 and the character is one that uses multiple bytes (basically one that is not between a space and an tilde ) then use KCOMPRESS() instead.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 20:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959825#M374455</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-02-20T20:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove specific character from a string value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959875#M374475</link>
      <description>You could use DEQUOTE() to get rid of quote around this string:&lt;BR /&gt;&lt;BR /&gt;Subject=dequote(Subject);</description>
      <pubDate>Fri, 21 Feb 2025 02:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959875#M374475</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-02-21T02:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove specific character from a string value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959897#M374478</link>
      <description>&lt;P&gt;&lt;SPAN&gt;It's because carriage return, I was not getting expected outcome. I tried with below code. Getting expected results. thank you.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;	subjectnumber=compress(Subject,'0D0A'x);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Feb 2025 05:08:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959897#M374478</guid>
      <dc:creator>PC7</dc:creator>
      <dc:date>2025-02-21T05:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove specific character from a string value.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959898#M374479</link>
      <description>&lt;P&gt;Hi Ksharp,&lt;/P&gt;&lt;P&gt;I tried with DQUOTE function, still I was getting same results. I think it's because of carriage return. When I tried the below code, Geeting expected outcome.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;	subjectnumber=compress(Subject,'0D0A'x);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2025 05:12:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-specific-character-from-a-string-value/m-p/959898#M374479</guid>
      <dc:creator>PC7</dc:creator>
      <dc:date>2025-02-21T05:12:03Z</dc:date>
    </item>
  </channel>
</rss>

