<?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: Reanaming observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reanaming-observations/m-p/355883#M83374</link>
    <description>&lt;P&gt;You want to replace strings of text separated by _ by their starting letter, but not the last part, correct?&lt;/P&gt;</description>
    <pubDate>Thu, 04 May 2017 08:31:56 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2017-05-04T08:31:56Z</dc:date>
    <item>
      <title>Reanaming observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reanaming-observations/m-p/355881#M83372</link>
      <description>&lt;P&gt;HI SAS Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am tryng to replace a group of words of an observations with its starting letter, is there is anyway to do this. Please help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample dataset.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data a;&lt;BR /&gt;input name$;&lt;BR /&gt;cards;&lt;BR /&gt;name_ks_a_dfdfdf&lt;BR /&gt;name_ks_a_hjhj&lt;BR /&gt;name_class__hhjghjh&lt;BR /&gt;name_class___jnjjjk&lt;BR /&gt;name_marks_ghgjk&lt;BR /&gt;name_marks_ghjkjk&lt;BR /&gt;;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output:&lt;/P&gt;&lt;P&gt;name1&lt;BR /&gt;n_k_a_dfdfdf&lt;BR /&gt;n_k_a_hjhj&lt;BR /&gt;n_c_hhjghjh&lt;BR /&gt;n_c_jnjjjk&lt;BR /&gt;n_m_ghgjk&lt;BR /&gt;n_m_ghjkjk&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Sanjay&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 08:30:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reanaming-observations/m-p/355881#M83372</guid>
      <dc:creator>sanjay1</dc:creator>
      <dc:date>2017-05-04T08:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: Reanaming observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reanaming-observations/m-p/355883#M83374</link>
      <description>&lt;P&gt;You want to replace strings of text separated by _ by their starting letter, but not the last part, correct?&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 08:31:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reanaming-observations/m-p/355883#M83374</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-05-04T08:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Reanaming observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reanaming-observations/m-p/355886#M83376</link>
      <description>&lt;P&gt;yes Exactly&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 08:34:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reanaming-observations/m-p/355886#M83376</guid>
      <dc:creator>sanjay1</dc:creator>
      <dc:date>2017-05-04T08:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Reanaming observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reanaming-observations/m-p/355887#M83377</link>
      <description>Yes Exactly</description>
      <pubDate>Thu, 04 May 2017 08:35:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reanaming-observations/m-p/355887#M83377</guid>
      <dc:creator>sanjay1</dc:creator>
      <dc:date>2017-05-04T08:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Reanaming observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reanaming-observations/m-p/355889#M83379</link>
      <description>&lt;P&gt;Weird request. &amp;nbsp;Sounds like your process is broken before this. &amp;nbsp;You can do it:&lt;/P&gt;
&lt;PRE&gt;data a;
  length name $200;
  input name $;
cards;
name_ks_a_dfdfdf
name_ks_a_hjhj
name_class__hhjghjh
name_class___jnjjjk
name_marks_ghgjk
name_marks_ghjkjk
;
run;
data want;
  set a;
  length new_name $200;
  new_name=catx("_","n",char(scan(name,2,"_"),1),reverse(scan(reverse(name),1,"_")));
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 May 2017 08:48:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reanaming-observations/m-p/355889#M83379</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-04T08:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Reanaming observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reanaming-observations/m-p/355928#M83395</link>
      <description>&lt;P&gt;One way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;length new_name $ 100 letter $ 1;&lt;/P&gt;
&lt;P&gt;n_words = countw(name, '_');&lt;/P&gt;
&lt;P&gt;if n_words &amp;lt;= 1 then return;&lt;/P&gt;
&lt;P&gt;do i=1 to n_words - 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;letter = scan(name, i, '_');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;new_name = catx('_', new_name, letter);&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;new_name = catx('_', new_name, scan(name, -1, '_'));&lt;/P&gt;
&lt;P&gt;drop letter;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 12:58:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reanaming-observations/m-p/355928#M83395</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-04T12:58:08Z</dc:date>
    </item>
  </channel>
</rss>

