<?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: Do until in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Do-until/m-p/43972#M11567</link>
    <description>You need to update the len value within the DO loop.&lt;BR /&gt;
Also, if you want to see the results of each iteration of the loop you need the OUTPUT within the loop as well.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data a;&lt;BR /&gt;
  input id $;&lt;BR /&gt;
  len=length(id);&lt;BR /&gt;
  a='0';&lt;BR /&gt;
  do until (len=5);&lt;BR /&gt;
    id=a||id;&lt;BR /&gt;
    len=length(id);&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
cards;&lt;BR /&gt;
1&lt;BR /&gt;
01&lt;BR /&gt;
001&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
You also should consider what might happen if the length of your input variable is greater than 5.</description>
    <pubDate>Tue, 05 Apr 2011 17:34:25 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2011-04-05T17:34:25Z</dc:date>
    <item>
      <title>Do until</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Do-until/m-p/43970#M11565</link>
      <description>HI i want to add '0' before the id variable by using do until can any one help me.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data a;&lt;BR /&gt;
input id $;&lt;BR /&gt;
len=length(id);&lt;BR /&gt;
do until (len=5);&lt;BR /&gt;
a='0';&lt;BR /&gt;
id=a||id;&lt;BR /&gt;
end;&lt;BR /&gt;
stop;&lt;BR /&gt;
output;&lt;BR /&gt;
cards;&lt;BR /&gt;
1&lt;BR /&gt;
01&lt;BR /&gt;
001&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
output&lt;BR /&gt;
00001&lt;BR /&gt;
00001&lt;BR /&gt;
00001</description>
      <pubDate>Tue, 05 Apr 2011 06:36:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Do-until/m-p/43970#M11565</guid>
      <dc:creator>R_Win</dc:creator>
      <dc:date>2011-04-05T06:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Do until</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Do-until/m-p/43971#M11566</link>
      <description>Must it be by using the do loop ?&lt;BR /&gt;
&lt;BR /&gt;
Or perhaps you can use the following&lt;BR /&gt;
&lt;BR /&gt;
data a;&lt;BR /&gt;
input id 8.;&lt;BR /&gt;
id2=put(id,z5.);&lt;BR /&gt;
cards;&lt;BR /&gt;
1&lt;BR /&gt;
01&lt;BR /&gt;
001&lt;BR /&gt;
;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 05 Apr 2011 09:53:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Do-until/m-p/43971#M11566</guid>
      <dc:creator>GertNissen</dc:creator>
      <dc:date>2011-04-05T09:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Do until</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Do-until/m-p/43972#M11567</link>
      <description>You need to update the len value within the DO loop.&lt;BR /&gt;
Also, if you want to see the results of each iteration of the loop you need the OUTPUT within the loop as well.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data a;&lt;BR /&gt;
  input id $;&lt;BR /&gt;
  len=length(id);&lt;BR /&gt;
  a='0';&lt;BR /&gt;
  do until (len=5);&lt;BR /&gt;
    id=a||id;&lt;BR /&gt;
    len=length(id);&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
cards;&lt;BR /&gt;
1&lt;BR /&gt;
01&lt;BR /&gt;
001&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
You also should consider what might happen if the length of your input variable is greater than 5.</description>
      <pubDate>Tue, 05 Apr 2011 17:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Do-until/m-p/43972#M11567</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-04-05T17:34:25Z</dc:date>
    </item>
  </channel>
</rss>

