<?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: Adding Dashes to Text in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540145#M74098</link>
    <description>&lt;P&gt;Sorry:&lt;/P&gt;&lt;P&gt;I need a dash on the 5th and 9th location within the variable.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Mar 2019 18:49:26 GMT</pubDate>
    <dc:creator>altijani</dc:creator>
    <dc:date>2019-03-04T18:49:26Z</dc:date>
    <item>
      <title>Adding Dashes to Text</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540133#M74093</link>
      <description>&lt;P&gt;Greetings community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this type of dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id&lt;/P&gt;&lt;P&gt;A123B12C123&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I need:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id&lt;/P&gt;&lt;P&gt;A123-B12-C123&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please let me know how to convert this dataset?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Altijani&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 18:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540133#M74093</guid>
      <dc:creator>altijani</dc:creator>
      <dc:date>2019-03-04T18:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Dashes to Text</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540136#M74094</link>
      <description>&lt;P&gt;It's really hard to generalize from a single example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want dashes between numbers that are followed by a letter? Or dashes after the fourth character and after the 7th character? Or is there some other rule?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 18:33:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540136#M74094</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-04T18:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Dashes to Text</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540140#M74095</link>
      <description>&lt;P&gt;The rule has multiple combinations. What I want is to break down the field by 4 (characters/numbers) followed by a dash, then 3 (characters/numbers) followed by a dash, and then will be 4 (characters/Numbers) left at the end.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 18:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540140#M74095</guid>
      <dc:creator>altijani</dc:creator>
      <dc:date>2019-03-04T18:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Dashes to Text</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540142#M74096</link>
      <description>&lt;P&gt;Fully agree to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; : please post more examples or describe the rule to be implemented.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guessed that a dash should be inserted between digit and letter. If "id" is 11 chars long, you can't store the version with dashes in it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data narf;

    length id $ 11 want $ 30;

    input id;
    
    want = prxchange('s/([A-Z]\d+)([A-Z]\d+)([A-Z]\d+)/$1-$2-$3/', -1, trim(id));
    
    datalines;
A123B12C123
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Mar 2019 18:47:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540142#M74096</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-03-04T18:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Dashes to Text</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540143#M74097</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    length newstring $ 13;
    str1=substr(text,1,4);
    str2=substr(text,5,3);
    str3=substr(text,8,4);
    newstring = cats(str1,'-',str2,'-',str3);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Mar 2019 18:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540143#M74097</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-04T18:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Dashes to Text</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540145#M74098</link>
      <description>&lt;P&gt;Sorry:&lt;/P&gt;&lt;P&gt;I need a dash on the 5th and 9th location within the variable.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 18:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540145#M74098</guid>
      <dc:creator>altijani</dc:creator>
      <dc:date>2019-03-04T18:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Dashes to Text</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540146#M74099</link>
      <description>&lt;P&gt;newId = catx("-", substr(id,1,4), substr(id,5,3), substr(id,8));&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 18:50:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540146#M74099</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-03-04T18:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Dashes to Text</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540149#M74100</link>
      <description>&lt;P&gt;As always, i thought to much &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 18:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540149#M74100</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-03-04T18:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Dashes to Text</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540423#M74103</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
x='A123B12C123';
want=prxchange('s/-$//',1,strip(prxchange('s/([a-z]+\d+)/$1-/i',-1,x)));

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Mar 2019 12:45:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-Dashes-to-Text/m-p/540423#M74103</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-03-05T12:45:52Z</dc:date>
    </item>
  </channel>
</rss>

