<?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 removing a character from variable value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/removing-a-character-from-variable-value/m-p/782470#M249441</link>
    <description>&lt;P&gt;I have a table ABC . ABC is having a column ONE&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Column one is having value like this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;month_num&amp;nbsp; week_in_month&amp;nbsp; &amp;nbsp;bc_type&amp;nbsp; &amp;nbsp;cycle&amp;nbsp; &amp;nbsp;event_daysnum&amp;nbsp; event_flag&amp;nbsp; SEGMENT_CD&amp;nbsp; BRAND_SEGMENT_CD SUBBRAND_CD&amp;nbsp; &amp;nbsp;FLAVOR_CD&amp;nbsp; &amp;nbsp;LH_CATEGORY_CD&amp;nbsp; &amp;nbsp;LH_MARKET_SEGMENT_CD&amp;nbsp; &amp;nbsp;LH_UMBRELLA_BRAND_CD LH_MATERIAL_BRAND_CD&amp;nbsp; &amp;nbsp;LH_SUBGRP_CD&amp;nbsp; &amp;nbsp;LH_MATERIAL_VARIANT_CD&amp;nbsp; &amp;nbsp;CUSTOMER_HIERARCHY_LVL1_CD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I&amp;nbsp; need to remove the&amp;nbsp; part &lt;SPAN&gt;&lt;STRONG&gt;MN_Natural_san_CD&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;, but keeping the rest of the table intact&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;month_num week_in_month bc_type cycle event_daysnum event_flag SEGMENT_CD BRAND_SEGMENT_CD SUBBRAND_CD FLAVOR_CD LH_CATEGORY_CD LH_MARKET_SEGMENT_CD LH_UMBRELLA_BRAND_CD LH_MATERIAL_BRAND_CD LH_SUBGRP_CD&amp;nbsp; &lt;STRONG&gt;MN_Natural_san_CD&lt;/STRONG&gt;&amp;nbsp;CUSTOMER_HIERARCHY_LVL1_CD&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;please help.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Tried&amp;nbsp; below code&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;data new;&lt;BR /&gt;set ABC;&lt;BR /&gt;one = compress(one,"&lt;SPAN&gt;&lt;STRONG&gt;MN_Natural_san_CD&lt;/STRONG&gt;&lt;/SPAN&gt;");&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is not working&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. got value like this (Its incorrect )&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;monthnum weekinmonth bctype cycle eventdaysnum eventflag SG BSG SUBB FO GOY KSG UBB B SUBGP USOY1&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2.&amp;nbsp;&amp;nbsp;WARNING: Data too long for column "One"; truncated to 128 characters to fit.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Nov 2021 18:18:32 GMT</pubDate>
    <dc:creator>Aexor</dc:creator>
    <dc:date>2021-11-25T18:18:32Z</dc:date>
    <item>
      <title>removing a character from variable value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/removing-a-character-from-variable-value/m-p/782470#M249441</link>
      <description>&lt;P&gt;I have a table ABC . ABC is having a column ONE&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Column one is having value like this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;month_num&amp;nbsp; week_in_month&amp;nbsp; &amp;nbsp;bc_type&amp;nbsp; &amp;nbsp;cycle&amp;nbsp; &amp;nbsp;event_daysnum&amp;nbsp; event_flag&amp;nbsp; SEGMENT_CD&amp;nbsp; BRAND_SEGMENT_CD SUBBRAND_CD&amp;nbsp; &amp;nbsp;FLAVOR_CD&amp;nbsp; &amp;nbsp;LH_CATEGORY_CD&amp;nbsp; &amp;nbsp;LH_MARKET_SEGMENT_CD&amp;nbsp; &amp;nbsp;LH_UMBRELLA_BRAND_CD LH_MATERIAL_BRAND_CD&amp;nbsp; &amp;nbsp;LH_SUBGRP_CD&amp;nbsp; &amp;nbsp;LH_MATERIAL_VARIANT_CD&amp;nbsp; &amp;nbsp;CUSTOMER_HIERARCHY_LVL1_CD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I&amp;nbsp; need to remove the&amp;nbsp; part &lt;SPAN&gt;&lt;STRONG&gt;MN_Natural_san_CD&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;, but keeping the rest of the table intact&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;month_num week_in_month bc_type cycle event_daysnum event_flag SEGMENT_CD BRAND_SEGMENT_CD SUBBRAND_CD FLAVOR_CD LH_CATEGORY_CD LH_MARKET_SEGMENT_CD LH_UMBRELLA_BRAND_CD LH_MATERIAL_BRAND_CD LH_SUBGRP_CD&amp;nbsp; &lt;STRONG&gt;MN_Natural_san_CD&lt;/STRONG&gt;&amp;nbsp;CUSTOMER_HIERARCHY_LVL1_CD&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;please help.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Tried&amp;nbsp; below code&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;data new;&lt;BR /&gt;set ABC;&lt;BR /&gt;one = compress(one,"&lt;SPAN&gt;&lt;STRONG&gt;MN_Natural_san_CD&lt;/STRONG&gt;&lt;/SPAN&gt;");&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is not working&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. got value like this (Its incorrect )&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;monthnum weekinmonth bctype cycle eventdaysnum eventflag SG BSG SUBB FO GOY KSG UBB B SUBGP USOY1&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2.&amp;nbsp;&amp;nbsp;WARNING: Data too long for column "One"; truncated to 128 characters to fit.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 18:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/removing-a-character-from-variable-value/m-p/782470#M249441</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2021-11-25T18:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: removing a character from variable value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/removing-a-character-from-variable-value/m-p/782471#M249442</link>
      <description>&lt;P&gt;COMPRESS() is for removing individual characters.&lt;/P&gt;
&lt;P&gt;You can use TRANWRD()&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
  set ABC;
  one = tranwrd(one,"MN_Natural_san_CD",' ');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or TRANSTRN() function instead.&amp;nbsp; The second is useful when you want remove the substring instead of just replacing it with one or more spaces.&amp;nbsp; Use the TRIMN() function to generate an empty string for the third argument.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
  set ABC;
  one = transtrn(one,"MN_Natural_san_CD",trimn(' '));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Nov 2021 18:28:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/removing-a-character-from-variable-value/m-p/782471#M249442</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-25T18:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: removing a character from variable value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/removing-a-character-from-variable-value/m-p/782472#M249443</link>
      <description>&lt;P&gt;Note that it will be much easier to deal with that list of variable names if each one was in its own observation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data names;
  set ABC ;
  length name $32;
  do index=1 to countw(one,' ');
     name=scan(one,index,' ');
     output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Nov 2021 18:30:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/removing-a-character-from-variable-value/m-p/782472#M249443</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-25T18:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: removing a character from variable value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/removing-a-character-from-variable-value/m-p/782474#M249445</link>
      <description>Thanks for suggestion. missed to mention one point here.&lt;BR /&gt;&lt;BR /&gt;I don't want to create a new table. I want to modify the same table.&lt;BR /&gt;&lt;BR /&gt;So here I don't want to create new, I want to modify ABC so after removing the variable value I will get the required updated column in the same table.&lt;BR /&gt;Can you suggest something please.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 25 Nov 2021 18:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/removing-a-character-from-variable-value/m-p/782474#M249445</guid>
      <dc:creator>Aexor</dc:creator>
      <dc:date>2021-11-25T18:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: removing a character from variable value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/removing-a-character-from-variable-value/m-p/782475#M249446</link>
      <description>&lt;P&gt;Please explain the larger context of what you are doing.&amp;nbsp; It really looks like you are dealing with a list of variable names.&amp;nbsp; That will work much better if you keep each name in a separate observation.&amp;nbsp; Then you can filter the list just using a WHERE statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You CAN replace a dataset (just use the same name on the DATA and SET statements), but it is generally not a good idea as then you have lost your original version. It is especially to be discouraged for novice programmers that might not understand all of the potential side effects when the code does not run as intended.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 18:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/removing-a-character-from-variable-value/m-p/782475#M249446</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-25T18:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: removing a character from variable value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/removing-a-character-from-variable-value/m-p/782483#M249451</link>
      <description>&lt;P&gt;I only read half of it (the original question), but the below blog might be useful :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Deleting a substring from a SAS string&lt;BR /&gt;By Leonid Batkhan on SAS Users February 22, 2021&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/sgf/2021/02/22/deleting-a-substring-from-a-sas-string/" target="_blank"&gt;https://blogs.sas.com/content/sgf/2021/02/22/deleting-a-substring-from-a-sas-string/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 21:15:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/removing-a-character-from-variable-value/m-p/782483#M249451</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-11-25T21:15:16Z</dc:date>
    </item>
  </channel>
</rss>

