<?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: New column, Counting observations? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-Counting-observations/m-p/3046#M965</link>
    <description>Hello&lt;BR /&gt;
&lt;BR /&gt;
This is the solution. I suppose that data are in the the table named XXX and it is sorted by ID, DATE XYZ. The ZZZ table contains Z wich it counts the number of observations in each ID.&lt;BR /&gt;
&lt;BR /&gt;
data ZZZ;&lt;BR /&gt;
	retain Z 0;&lt;BR /&gt;
	set XXX;&lt;BR /&gt;
	by ID;&lt;BR /&gt;
	if first.id then Z=0;&lt;BR /&gt;
	Z+1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards,</description>
    <pubDate>Tue, 15 May 2007 10:02:08 GMT</pubDate>
    <dc:creator>Victor</dc:creator>
    <dc:date>2007-05-15T10:02:08Z</dc:date>
    <item>
      <title>New column, Counting observations?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-Counting-observations/m-p/3045#M964</link>
      <description>Is there a way to compute a column that counts observations and puts the current # in the new column.&lt;BR /&gt;
DATA:&lt;BR /&gt;
ID   Date   XYZ                 &lt;B&gt;new column would show&lt;/B&gt;&lt;BR /&gt;
1    06      123                                &lt;B&gt;1&lt;/B&gt;&lt;BR /&gt;
1    07      124                                &lt;B&gt;2&lt;/B&gt;&lt;BR /&gt;
2    06      113                                &lt;B&gt;1&lt;/B&gt;&lt;BR /&gt;
3    06      234                             &lt;B&gt;   1&lt;/B&gt;&lt;BR /&gt;
3    06      235                               &lt;B&gt; 2&lt;/B&gt;&lt;BR /&gt;
3    07      345                               &lt;B&gt; 3&lt;/B&gt;</description>
      <pubDate>Mon, 14 May 2007 20:10:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-Counting-observations/m-p/3045#M964</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-05-14T20:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: New column, Counting observations?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-Counting-observations/m-p/3046#M965</link>
      <description>Hello&lt;BR /&gt;
&lt;BR /&gt;
This is the solution. I suppose that data are in the the table named XXX and it is sorted by ID, DATE XYZ. The ZZZ table contains Z wich it counts the number of observations in each ID.&lt;BR /&gt;
&lt;BR /&gt;
data ZZZ;&lt;BR /&gt;
	retain Z 0;&lt;BR /&gt;
	set XXX;&lt;BR /&gt;
	by ID;&lt;BR /&gt;
	if first.id then Z=0;&lt;BR /&gt;
	Z+1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Regards,</description>
      <pubDate>Tue, 15 May 2007 10:02:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-Counting-observations/m-p/3046#M965</guid>
      <dc:creator>Victor</dc:creator>
      <dc:date>2007-05-15T10:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: New column, Counting observations?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-Counting-observations/m-p/3047#M966</link>
      <description>Thank you for the note. I'm afraid I was unable to make this work. In Enterprise Guide, where would I put this code? I tried it in the compute column box, but it doesn't get past "Retain" before it calls this a syntax error.</description>
      <pubDate>Tue, 15 May 2007 23:02:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-Counting-observations/m-p/3047#M966</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-05-15T23:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: New column, Counting observations?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-Counting-observations/m-p/3048#M967</link>
      <description>Joe,&lt;BR /&gt;
&lt;BR /&gt;
Victor's approach requires creating a Code Task to directly write the code; it's can't be used as an expression in the Query Task.  I'm not sure how to do it in a query task, as SQL is inherently non-ordered in it's operations.&lt;BR /&gt;
&lt;BR /&gt;
Doc Muhlbaier&lt;BR /&gt;
Duke</description>
      <pubDate>Wed, 16 May 2007 02:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/New-column-Counting-observations/m-p/3048#M967</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2007-05-16T02:03:07Z</dc:date>
    </item>
  </channel>
</rss>

