<?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: First by Groups in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/First-by-Groups/m-p/390709#M93752</link>
    <description>&lt;P&gt;It's very similar to this question, except you want a character value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use the method in the link, you can then recode 1 to "First" and anything else to "Returning".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Aug 2017 18:07:40 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-08-24T18:07:40Z</dc:date>
    <item>
      <title>First by Groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-by-Groups/m-p/390707#M93750</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset like this currently;&lt;/P&gt;&lt;P&gt;id term program&lt;BR /&gt;1 201102 Arts&lt;BR /&gt;1 201103 Arts&lt;BR /&gt;1 201201 Metal&lt;BR /&gt;2 200701 Arts&lt;BR /&gt;2 200702 Arts&lt;BR /&gt;3 201003 Arts&lt;BR /&gt;3 201003 Arts&lt;BR /&gt;3 201003 Arts&lt;BR /&gt;3 201201 Fashion&lt;BR /&gt;3 201202 Fashion&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a new variable called "First_Term" and identify the first term by program, term and id. It should look like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id term program First_term&lt;BR /&gt;1 201102 Arts &amp;nbsp; &amp;nbsp;First term&lt;BR /&gt;1 201103 Arts &amp;nbsp; &amp;nbsp;Returning&lt;BR /&gt;1 201201 Metal &amp;nbsp;First term&lt;BR /&gt;2 200701 Arts &amp;nbsp; &amp;nbsp;First term&lt;BR /&gt;2 200702 Arts &amp;nbsp; &amp;nbsp;Returning&lt;BR /&gt;3 201003 Arts &amp;nbsp; &amp;nbsp;First term&lt;BR /&gt;3 201003 Arts &amp;nbsp; &amp;nbsp;Returning&lt;BR /&gt;3 201003 Arts &amp;nbsp; &amp;nbsp;Returning&lt;BR /&gt;3 201201 Fashion First term&lt;BR /&gt;3 201202 Fashion Returning&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not know how to do this? Please help.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 18:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-by-Groups/m-p/390707#M93750</guid>
      <dc:creator>anandas</dc:creator>
      <dc:date>2017-08-24T18:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: First by Groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-by-Groups/m-p/390709#M93752</link>
      <description>&lt;P&gt;It's very similar to this question, except you want a character value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use the method in the link, you can then recode 1 to "First" and anything else to "Returning".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 18:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-by-Groups/m-p/390709#M93752</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-24T18:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: First by Groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-by-Groups/m-p/390726#M93764</link>
      <description>&lt;P&gt;In the long term, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;is 100% right in that you need to study and learn these tools.&amp;nbsp; However, beginning with a problem that requires&amp;nbsp;your data sorted by 3 variables might be a little daunting.&amp;nbsp; So here is one way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by id program term;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by id program;&lt;/P&gt;
&lt;P&gt;if first.program then first_term='First term';&lt;/P&gt;
&lt;P&gt;else first_term='Returning';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I made some assumptions about what is really needed here, since the rules for assigning "First term" vs. "Returning" don't appear (to me) to be consistent in your example.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 18:38:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-by-Groups/m-p/390726#M93764</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-24T18:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: First by Groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-by-Groups/m-p/390730#M93767</link>
      <description>&lt;P&gt;Thank you to both. I looked at Reeza's article and replaced with string and worked like a charm. Earlier I was using the same code only but to use 'and' instead of 'or'.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2017 19:11:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-by-Groups/m-p/390730#M93767</guid>
      <dc:creator>anandas</dc:creator>
      <dc:date>2017-08-24T19:11:02Z</dc:date>
    </item>
  </channel>
</rss>

