<?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: auto id in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/auto-id/m-p/337688#M63082</link>
    <description>&lt;P&gt;There is already an automatic variable that does that. You just have to capture it in a data step. e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
  set sashelp.class;
  count=_n_;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
    <pubDate>Fri, 03 Mar 2017 01:41:04 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-03-03T01:41:04Z</dc:date>
    <item>
      <title>auto id</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/auto-id/m-p/337686#M63081</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I create a new variable named 'Count' that starts at 1 on row 1 and increases by 1 increment through the last observation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible to do this using proc sql?&amp;nbsp; Or is it better to do it using the data stet?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 01:28:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/auto-id/m-p/337686#M63081</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2017-03-03T01:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: auto id</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/auto-id/m-p/337688#M63082</link>
      <description>&lt;P&gt;There is already an automatic variable that does that. You just have to capture it in a data step. e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
  set sashelp.class;
  count=_n_;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 01:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/auto-id/m-p/337688#M63082</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-03T01:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: auto id</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/auto-id/m-p/337757#M63084</link>
      <description>&lt;P&gt;The question would be why. &amp;nbsp;It sounds like your coming from SQL to SAS and there is an understanding gap between the two. &amp;nbsp;SQL does not assume sorted data - in fact apart from grouping and ordering, data can go in any way - hence why there are functions to create these types of ID field either automatically or by hand. &amp;nbsp;In SAS however it is different, the basic functionality expects sorted data - i.e. by group processing (there is the unsorted option - however that doesn't mean the data is not sorted, just not logically). &amp;nbsp;So as your data will always be in group by order for any processing, and id field should not be necessary, and if it is needed for some logic then you can just use _n_.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 09:42:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/auto-id/m-p/337757#M63084</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-03T09:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: auto id</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/auto-id/m-p/338064#M63092</link>
      <description>&lt;P&gt;This works!&amp;nbsp; Is there a way to get this as the first column in the output?&amp;nbsp; Right now, it is the last.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 23:02:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/auto-id/m-p/338064#M63092</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2017-03-03T23:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: auto id</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/auto-id/m-p/338066#M63093</link>
      <description>&lt;P&gt;Of course! Just add a retain statement before the set statement. E.g.,:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
  retain count;
  set sashelp.class;
  count=_n_;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 23:07:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/auto-id/m-p/338066#M63093</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-03T23:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: auto id</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/auto-id/m-p/338068#M63095</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 23:13:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/auto-id/m-p/338068#M63095</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2017-03-03T23:13:25Z</dc:date>
    </item>
  </channel>
</rss>

