<?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 Distinct numbering in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Distinct-numbering/m-p/32713#M4270</link>
    <description>I have a table that looks like this&lt;BR /&gt;
A&lt;BR /&gt;
A&lt;BR /&gt;
A&lt;BR /&gt;
B&lt;BR /&gt;
B&lt;BR /&gt;
&lt;BR /&gt;
How can I create an id column that will look like this&lt;BR /&gt;
1 A&lt;BR /&gt;
1 A&lt;BR /&gt;
1 A&lt;BR /&gt;
2 B&lt;BR /&gt;
2 B&lt;BR /&gt;
&lt;BR /&gt;
Thank you for your help</description>
    <pubDate>Tue, 08 Jun 2010 16:46:37 GMT</pubDate>
    <dc:creator>jerry898969</dc:creator>
    <dc:date>2010-06-08T16:46:37Z</dc:date>
    <item>
      <title>Distinct numbering</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Distinct-numbering/m-p/32713#M4270</link>
      <description>I have a table that looks like this&lt;BR /&gt;
A&lt;BR /&gt;
A&lt;BR /&gt;
A&lt;BR /&gt;
B&lt;BR /&gt;
B&lt;BR /&gt;
&lt;BR /&gt;
How can I create an id column that will look like this&lt;BR /&gt;
1 A&lt;BR /&gt;
1 A&lt;BR /&gt;
1 A&lt;BR /&gt;
2 B&lt;BR /&gt;
2 B&lt;BR /&gt;
&lt;BR /&gt;
Thank you for your help</description>
      <pubDate>Tue, 08 Jun 2010 16:46:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Distinct-numbering/m-p/32713#M4270</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2010-06-08T16:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct numbering</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Distinct-numbering/m-p/32714#M4271</link>
      <description>First./last. processing using DATA step code would be the easiest method. I can't think of a good way to do this via the query builder or a data task... but maybe someone else will come up with something there. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
  /* Create data as an example for this */&lt;BR /&gt;
data temp;&lt;BR /&gt;
  input charcol : $1.;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
A&lt;BR /&gt;
A&lt;BR /&gt;
A&lt;BR /&gt;
B&lt;BR /&gt;
A&lt;BR /&gt;
C&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
  /* Pre-sort the data by the variable in question, very important */&lt;BR /&gt;
proc sort data=temp out=tempsort;&lt;BR /&gt;
  by charcol;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
  /* Use a BY statement for the sorted variable */&lt;BR /&gt;
data temp2;&lt;BR /&gt;
  set tempsort;&lt;BR /&gt;
  by charcol;&lt;BR /&gt;
  if first.charcol=1 then id+1;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 08 Jun 2010 17:19:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Distinct-numbering/m-p/32714#M4271</guid>
      <dc:creator>RichardH_sas</dc:creator>
      <dc:date>2010-06-08T17:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct numbering</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Distinct-numbering/m-p/32715#M4272</link>
      <description>Richard,&lt;BR /&gt;
Thank you so much that was it.  &lt;BR /&gt;
&lt;BR /&gt;
I have to find a way to grasp the way sas handles data compared to other DBMS.&lt;BR /&gt;
&lt;BR /&gt;
Thank you again</description>
      <pubDate>Tue, 08 Jun 2010 17:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Distinct-numbering/m-p/32715#M4272</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2010-06-08T17:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct numbering</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Distinct-numbering/m-p/32716#M4273</link>
      <description>Richard,&lt;BR /&gt;
Sorry to bother but I have a follow up question based off of the first one.&lt;BR /&gt;
&lt;BR /&gt;
Say now I have a second column that has data in it&lt;BR /&gt;
&lt;BR /&gt;
A A&lt;BR /&gt;
A A&lt;BR /&gt;
A B &lt;BR /&gt;
A C&lt;BR /&gt;
B A&lt;BR /&gt;
B C&lt;BR /&gt;
C A &lt;BR /&gt;
C A&lt;BR /&gt;
C A&lt;BR /&gt;
C B&lt;BR /&gt;
&lt;BR /&gt;
I need the ids to do the same for the second column kind of like we did for the first.&lt;BR /&gt;
&lt;BR /&gt;
A A 1 1&lt;BR /&gt;
A A 1 1&lt;BR /&gt;
A B 1 2 &lt;BR /&gt;
A C 1 3&lt;BR /&gt;
B A 2 1&lt;BR /&gt;
B C 2 2&lt;BR /&gt;
C A 3 1 &lt;BR /&gt;
C A 3 1&lt;BR /&gt;
C A 3 1&lt;BR /&gt;
C B 3 2&lt;BR /&gt;
&lt;BR /&gt;
Sorry if this is confusing.  I have 4 columns that I have to id this way.  &lt;BR /&gt;
&lt;BR /&gt;
Thank You</description>
      <pubDate>Tue, 08 Jun 2010 17:41:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Distinct-numbering/m-p/32716#M4273</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2010-06-08T17:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct numbering</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Distinct-numbering/m-p/32717#M4274</link>
      <description>I have run into another issue with the way my data needs to be numbered and I can't seem to find a way to do it.  &lt;BR /&gt;
&lt;BR /&gt;
If I have &lt;BR /&gt;
A A&lt;BR /&gt;
A B&lt;BR /&gt;
A &lt;BR /&gt;
A C&lt;BR /&gt;
A D&lt;BR /&gt;
&lt;BR /&gt;
I need a way for my numbering to skip the blanks without adding 1 to the counter.&lt;BR /&gt;
&lt;BR /&gt;
A A 1 1&lt;BR /&gt;
A B 1 2&lt;BR /&gt;
A    1&lt;BR /&gt;
A C 1 3&lt;BR /&gt;
A D 1 4&lt;BR /&gt;
&lt;BR /&gt;
I need my counter to not increment on the 3rd row so the 4th row will continue from the id on the second row.&lt;BR /&gt;
&lt;BR /&gt;
Any help would be greatly appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Thank You</description>
      <pubDate>Wed, 09 Jun 2010 13:13:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Distinct-numbering/m-p/32717#M4274</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2010-06-09T13:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct numbering</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Distinct-numbering/m-p/32718#M4275</link>
      <description>Something like this should work.  May not be exactly what you are looking for, but let me know.&lt;BR /&gt;
&lt;BR /&gt;
/* Create data as an example for this */&lt;BR /&gt;
data temp;&lt;BR /&gt;
 infile datalines dsd delimiter=',';&lt;BR /&gt;
 attrib charcol1 length = $1&lt;BR /&gt;
 		charcol2 length = $1;&lt;BR /&gt;
 input 	charcol1 $&lt;BR /&gt;
		charcol2 $;&lt;BR /&gt;
 datalines;&lt;BR /&gt;
A,A&lt;BR /&gt;
A,B&lt;BR /&gt;
A,&lt;BR /&gt;
A,C&lt;BR /&gt;
A,D&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* Pre-sort the data by the variable in question, very important */&lt;BR /&gt;
proc sort data=temp out=tempsort;&lt;BR /&gt;
	by charcol1 charcol2;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* Use a BY statement for the sorted variable */&lt;BR /&gt;
data temp2;&lt;BR /&gt;
set tempsort;&lt;BR /&gt;
retain charcol1 charcol2;&lt;BR /&gt;
by charcol1 charcol2;&lt;BR /&gt;
if first.charcol1 then id+1;&lt;BR /&gt;
if first.charcol2 and charcol2 NE ' ' then id2+1;&lt;BR /&gt;
if id2=0 then id2=.;&lt;BR /&gt;
run; &lt;BR /&gt;
&lt;BR /&gt;
A		1	.&lt;BR /&gt;
A	A	1	1&lt;BR /&gt;
A	B	1	2&lt;BR /&gt;
A	C	1	3&lt;BR /&gt;
A	D	1	4</description>
      <pubDate>Wed, 09 Jun 2010 13:43:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Distinct-numbering/m-p/32718#M4275</guid>
      <dc:creator>jklein271</dc:creator>
      <dc:date>2010-06-09T13:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct numbering</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Distinct-numbering/m-p/32719#M4276</link>
      <description>jklein,&lt;BR /&gt;
&lt;BR /&gt;
Thank you so much for the help.  Your code helped me get it working.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Jerry</description>
      <pubDate>Wed, 09 Jun 2010 13:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Distinct-numbering/m-p/32719#M4276</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2010-06-09T13:58:12Z</dc:date>
    </item>
  </channel>
</rss>

