<?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: Concat by maintaining space or adding between strings in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Concat-by-maintaining-space-or-adding-between-strings/m-p/519160#M3740</link>
    <description>&lt;P&gt;hi Ballardw, your solution works for me as well, thank you. Also, apologies for not including the example in sample data; I won't make this mistake again in future posts.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Dec 2018 15:41:20 GMT</pubDate>
    <dc:creator>brulard</dc:creator>
    <dc:date>2018-12-06T15:41:20Z</dc:date>
    <item>
      <title>Concat by maintaining space or adding between strings</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concat-by-maintaining-space-or-adding-between-strings/m-p/518933#M3677</link>
      <description>&lt;P&gt;hi , I'm trying to concat three values, into a new value, where I want them spaced in such a fashion that when looking at the strings within the variable denominated say by a | (pipe),&amp;nbsp;they would be spaced in a consistent manner... Ie, the date would&amp;nbsp; always begin from end of say a $200 length NewVar, or always begining at say , digit space +185.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde"&gt;Current code&lt;/FONT&gt; used to concat 3 columns:&amp;nbsp;NewVar= CATX(' | ', ID ,IssueName,put(CurrentTargetDate,mmddyy10.));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde"&gt;Current output:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;149 | SOL Address Change Issue | 12/28/2018&lt;BR /&gt;196 | BOND - Delayed File Processing | 01/11/2019&lt;BR /&gt;58 | Document Retention | 03/04/2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde"&gt;Wanted output:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;149 |&amp;nbsp;&lt;SPAN&gt;SOL Address Change Issue |&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12/28/2018&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;196 | BOND - Delayed File Processing |&amp;nbsp; &amp;nbsp; 01/11/2019&lt;BR /&gt;58&amp;nbsp; &amp;nbsp;| Document Retention |&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03/04/2019&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial black,avant garde"&gt;Sample data&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID IssueName CurrentTargetDate&lt;BR /&gt;179 MRV Error Message on SPOON Application in Store 12/7/2018&lt;BR /&gt;195 Credit Bureau Impact due to CCT Change 12/14/2018&lt;BR /&gt;165 SPP Segment Pricing on Passport Infinite 12/21/2018&lt;BR /&gt;203 GM/SOF Bounty and Incentive Control Enhancements 1/18/2019&lt;BR /&gt;156 Purchase Promo Reach Back 2/1/2019&lt;BR /&gt;185 OFG Team Member Promo 2/6/2019&lt;BR /&gt;153 PAD Issue for Visa Scene New Bin Number 2/8/2019&lt;BR /&gt;191 Promo Rate Display Location.com 2/8/2019&lt;BR /&gt;192 Duplicate Scotialine with Access Card Setups 2/8/2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 20:18:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concat-by-maintaining-space-or-adding-between-strings/m-p/518933#M3677</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2018-12-05T20:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: Concat by maintaining space or adding between strings</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concat-by-maintaining-space-or-adding-between-strings/m-p/518936#M3678</link>
      <description>So no trailing spaces, but maintain leading spaces? I think you need a different CAT function, try CATT instead?</description>
      <pubDate>Wed, 05 Dec 2018 20:29:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concat-by-maintaining-space-or-adding-between-strings/m-p/518936#M3678</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-05T20:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Concat by maintaining space or adding between strings</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concat-by-maintaining-space-or-adding-between-strings/m-p/518974#M3691</link>
      <description>&lt;P&gt;To get everything to line up, you need to know the maximum number of characters required by each variable.&amp;nbsp; In this example, I will use $50 as the length of IssueName.&amp;nbsp; To get everything to line up, you could use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;newvar = '     |                                                    |         ';
substr(newvar, 2, 3) = id;
substr(newvar, 7, 50) = IssueName;
substr(newvar, 61, 8) = put(CurrentTargetDate, mmddyy10.);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once you are lining up the interior data, it is possible that you don't need the pipes any more.&amp;nbsp; But that would depend on where you are heading with this down the road.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The pipes are also going to line up in the code I supplied ... probably a better way than having the pipes switch position depending on the length of the variables.&amp;nbsp; But that can be changed if necessary.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 22:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concat-by-maintaining-space-or-adding-between-strings/m-p/518974#M3691</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-12-05T22:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Concat by maintaining space or adding between strings</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concat-by-maintaining-space-or-adding-between-strings/m-p/518978#M3692</link>
      <description>&lt;P&gt;It might help to include your worked examples in the "Sample data". It is not clear as posted whether your worked examples would have removed things from the base data. Worked examples should always start with sample data.&lt;/P&gt;
&lt;P&gt;Also you say "for example digit space +185". What do you want to happen if the concatenated bits of ID and Issue exceed 185 (or any given position)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
   infile datalines dlm='|';
   informat id best5. IssueName $100. CurrentTargetDate mmddyy10.;
   input id issuename currenttargetdate;
datalines;
179|MRV Error Message on SPOON Application in Store|12/7/2018
195|Credit Bureau Impact due to CCT Change|12/14/2018
165|SPP Segment Pricing on Passport Infinite|12/21/2018
203|GM/SOF Bounty and Incentive Control Enhancements|1/18/2019
156|Purchase Promo Reach Back|2/1/2019
185|OFG Team Member Promo|2/6/2019
153|PAD Issue for Visa Scene New Bin Number|2/8/2019
191|Promo Rate Display Location.com|2/8/2019
192|Duplicate Scotialine with Access Card Setups|2/8/2019
;
run;

data want;
   set have;
/*   file 'x:\data\junk.txt';*/
   length newvar $200.;
   datepos=185;
   x=length(catx('|',id, issuename) );
   newvar=catt(catx('|',id, issuename),cat('|',repeat(' ',datepos-(x+3)),put(currenttargetdate,mmddyy10.)) );
/*   put newvar;*/
   drop datepos x;
run;


&lt;/PRE&gt;
&lt;P&gt;Since it is going to be a tad difficult to verify that the data starts on col 185, the datepos variable if your issuename may contain digits you could remove the comments for the file and put statement and examine the result in an editor that shows the column positions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 23:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concat-by-maintaining-space-or-adding-between-strings/m-p/518978#M3692</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-05T23:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Concat by maintaining space or adding between strings</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concat-by-maintaining-space-or-adding-between-strings/m-p/519155#M3739</link>
      <description>Thanks Reeza, let me consider that...</description>
      <pubDate>Thu, 06 Dec 2018 15:23:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concat-by-maintaining-space-or-adding-between-strings/m-p/519155#M3739</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2018-12-06T15:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: Concat by maintaining space or adding between strings</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concat-by-maintaining-space-or-adding-between-strings/m-p/519160#M3740</link>
      <description>&lt;P&gt;hi Ballardw, your solution works for me as well, thank you. Also, apologies for not including the example in sample data; I won't make this mistake again in future posts.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 15:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concat-by-maintaining-space-or-adding-between-strings/m-p/519160#M3740</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2018-12-06T15:41:20Z</dc:date>
    </item>
  </channel>
</rss>

