<?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: Repeat function with different length in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Repeat-function-with-different-length/m-p/264429#M18353</link>
    <description>&lt;P&gt;If your using query builder you can use the repeat function in a calculated column with the same parameters.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 17 Apr 2016 17:12:00 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-04-17T17:12:00Z</dc:date>
    <item>
      <title>Repeat function with different length</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Repeat-function-with-different-length/m-p/264418#M18350</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.0pt;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;Hi guys&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;Need help with the repeat function, can someone help pls?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;Here is the sample code, just copy and paste:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;I want to feel the new_name variable with the var "name" + "@" deppending on the length of the "name" var to a maximum of 10 characters on the "new_name" var. For example, please see the image RESULT.JPG atteched, and the code below:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;RESULT.jpg:&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2828i1D30F22B4EADB164/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="RESULT.jpg" title="RESULT.jpg" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;I tried the repeat function but I cannot change the number of repetitions.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name $;
datalines;
ferrari
mclaren
red bull
renault
mercedes
jordan
minardi
force india
;
run;
data have;
set have;
lentgh_name = length(name);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P style="margin: 0cm; margin-bottom: .0001pt; line-height: 15.0pt; orphans: auto; text-align: start; widows: 1; -webkit-text-stroke-width: 0px; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;Thanks and regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Apr 2016 16:06:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Repeat-function-with-different-length/m-p/264418#M18350</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2016-04-17T16:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat function with different length</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Repeat-function-with-different-length/m-p/264424#M18351</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@anonymous_user﻿,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's first correct your first data step ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name &amp;amp; $11.;
datalines;
ferrari
mclaren
red bull
renault
mercedes
jordan
minardi
force india
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;List input without the "&amp;amp;" modifier would stop reading a value at the first blank (thus truncating 'red bull' to 'red', see your own result). Also, without a length specification (in the above code contained in the informat specification $11.) values would be truncated&amp;nbsp;to 8 characters (e.g. 'force india' to 'force in').&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know why you couldn't "change the number of repetitions" with the REPEAT function because you didn't post your function call. Please see how I used the function in the code below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
length new_name $11;
set have;
if length(name)&amp;lt;10 then new_name=cats(name, repeat('@',9-length(name)));
else new_name=name;
length_new_name = length(new_name);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I've always found it a bit counterintuitive that the REPEAT function returns n&lt;STRONG&gt;+1&lt;/STRONG&gt; repetitions of the first argument (without allowing -1 as the second argument), but that's how it is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that the longest name ('force india') has length 11. Maybe you want to increase the number of&amp;nbsp;@ signs by 1? If so, please change '10' and '9' to '11' and '10', respectively.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other options to achieve the same result include the SUBSTR, PRXCHANGE or TRANSLATE&amp;nbsp;function (the latter with care for embedded blanks).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Apr 2016 16:53:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Repeat-function-with-different-length/m-p/264424#M18351</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-04-17T16:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat function with different length</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Repeat-function-with-different-length/m-p/264426#M18352</link>
      <description>&lt;P&gt;data have;&lt;BR /&gt;input name $15.;&lt;BR /&gt;datalines;&lt;BR /&gt;ferrari&lt;BR /&gt;mclaren&lt;BR /&gt;red bull&lt;BR /&gt;renault&lt;BR /&gt;mercedes&lt;BR /&gt;jordan&lt;BR /&gt;minardi&lt;BR /&gt;force india&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want(drop=char i);&lt;BR /&gt;set have;&lt;BR /&gt;length new_name $15.;&lt;BR /&gt;char='@';&lt;BR /&gt;new_name=name;&lt;BR /&gt;do i=length(name)+1 to 10;&lt;BR /&gt; new_name=catt(new_name,char);&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Apr 2016 17:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Repeat-function-with-different-length/m-p/264426#M18352</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2016-04-17T17:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat function with different length</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Repeat-function-with-different-length/m-p/264429#M18353</link>
      <description>&lt;P&gt;If your using query builder you can use the repeat function in a calculated column with the same parameters.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Apr 2016 17:12:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Repeat-function-with-different-length/m-p/264429#M18353</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-17T17:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat function with different length</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Repeat-function-with-different-length/m-p/264435#M18354</link>
      <description>&lt;P&gt;If plan on limiting your new varaible to a length of 10, you can do this fairly simply:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;length new_name $ 10;&lt;/P&gt;
&lt;P&gt;new_name = trim(name) || '@@@@@@@@@@';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There may not be room int he new variable to store all the "@" characters, so you automatically lose the ones that you don't need.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Apr 2016 18:58:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Repeat-function-with-different-length/m-p/264435#M18354</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-17T18:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat function with different length</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Repeat-function-with-different-length/m-p/265197#M18400</link>
      <description>&lt;P&gt;&lt;FONT size="3" color="#0000FF"&gt;&lt;STRONG&gt;Thank you all for your help!&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 18:50:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Repeat-function-with-different-length/m-p/265197#M18400</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2016-04-20T18:50:56Z</dc:date>
    </item>
  </channel>
</rss>

