<?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: How to create Variable ID and increment in Datastep or Proc sql? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Variable-ID-and-increment-in-Datastep-or-Proc-sql/m-p/129663#M260522</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you aware that your first example will only provide 99 distinct ID values?&amp;nbsp; And your second only around 240?&amp;nbsp; Or if I interpret you correctly and both are to be part of the same series you will only get just over 340 values?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first example is easy:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Length ID $ 10 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have (obs = 99) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID = 'ABC.DEF.' || PUT (_N_, Z2.) ;&lt;/P&gt;&lt;P&gt;Run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 04 May 2013 10:35:10 GMT</pubDate>
    <dc:creator>RichardinOz</dc:creator>
    <dc:date>2013-05-04T10:35:10Z</dc:date>
    <item>
      <title>How to create Variable ID and increment in Datastep or Proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Variable-ID-and-increment-in-Datastep-or-Proc-sql/m-p/129662#M260521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to create Variable ID and increment in Datastep or Proc sql?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a requirement to create a variable called id and that should have values as stated in the below example. Any help would be greatly appreciated. Also is there a way to make it generic by automating with a Macro or inside a macro?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ID&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ABC.DEF.01&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ABC.DEF.02&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ABC.DEF.03&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ABC.DEF.04&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;-.-----and so on.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;or in other cases its like&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ID&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ABC.DEF.A1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ABC.DEF.A2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ABC.DEF.A3&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;...___&amp;nbsp; and so on&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;My thought is prolly to create 2 different columns, one with ABC.DEF and the other with 01.... and then concatenate them or maybe retain and increment?Well, I am not quite getting though. &lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 May 2013 07:40:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-Variable-ID-and-increment-in-Datastep-or-Proc-sql/m-p/129662#M260521</guid>
      <dc:creator>MarkWik</dc:creator>
      <dc:date>2013-05-04T07:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Variable ID and increment in Datastep or Proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Variable-ID-and-increment-in-Datastep-or-Proc-sql/m-p/129663#M260522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you aware that your first example will only provide 99 distinct ID values?&amp;nbsp; And your second only around 240?&amp;nbsp; Or if I interpret you correctly and both are to be part of the same series you will only get just over 340 values?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first example is easy:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Length ID $ 10 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have (obs = 99) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ID = 'ABC.DEF.' || PUT (_N_, Z2.) ;&lt;/P&gt;&lt;P&gt;Run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 May 2013 10:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-Variable-ID-and-increment-in-Datastep-or-Proc-sql/m-p/129663#M260522</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2013-05-04T10:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Variable ID and increment in Datastep or Proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Variable-ID-and-increment-in-Datastep-or-Proc-sql/m-p/129664#M260523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For the second part&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data wantmore ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have (firstobs = 100 obs = 343) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Retain alpha 65 numero 0 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; numero + 1 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;ID = 'ABC.DEF.' || trim (byte (alpha)) || put (numero, 1.) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if numero = 9 then &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alpha + 1 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; numero = 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Run ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alert! untested code...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 May 2013 10:50:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-Variable-ID-and-increment-in-Datastep-or-Proc-sql/m-p/129664#M260523</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2013-05-04T10:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Variable ID and increment in Datastep or Proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Variable-ID-and-increment-in-Datastep-or-Proc-sql/m-p/129665#M260524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, above code designed for Windows, should work on Unix;&amp;nbsp; but on zOS you will have to look up the EBCDIC collating sequence and deal with the split in the alphabet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 May 2013 10:51:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-Variable-ID-and-increment-in-Datastep-or-Proc-sql/m-p/129665#M260524</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2013-05-04T10:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to create Variable ID and increment in Datastep or Proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-Variable-ID-and-increment-in-Datastep-or-Proc-sql/m-p/129666#M260525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Richard,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks very much indeed. That was so helpful and well explained too. Cheers mate. I didn't know z2. format would give leading zeros.hmmmm!!!.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for taking the time to answer on a weekend,&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 May 2013 06:53:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-Variable-ID-and-increment-in-Datastep-or-Proc-sql/m-p/129666#M260525</guid>
      <dc:creator>MarkWik</dc:creator>
      <dc:date>2013-05-05T06:53:54Z</dc:date>
    </item>
  </channel>
</rss>

