<?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 How to create a variable with n levels based on the size of the data in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-variable-with-n-levels-based-on-the-size-of-the/m-p/50760#M13860</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To explain what I want, please let me show the simple code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=work.city;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by descending gdp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I want to create a variable in the data work.city, which indicates the group that the case belongs to based on its gdp level. Group 1 has the largest gdp, and group 10 has the lowest gdp. Each group has equal number of cases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ruth.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 18 Aug 2011 18:08:57 GMT</pubDate>
    <dc:creator>Ruth</dc:creator>
    <dc:date>2011-08-18T18:08:57Z</dc:date>
    <item>
      <title>How to create a variable with n levels based on the size of the data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-variable-with-n-levels-based-on-the-size-of-the/m-p/50760#M13860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To explain what I want, please let me show the simple code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=work.city;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by descending gdp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I want to create a variable in the data work.city, which indicates the group that the case belongs to based on its gdp level. Group 1 has the largest gdp, and group 10 has the lowest gdp. Each group has equal number of cases.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ruth.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2011 18:08:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-variable-with-n-levels-based-on-the-size-of-the/m-p/50760#M13860</guid>
      <dc:creator>Ruth</dc:creator>
      <dc:date>2011-08-18T18:08:57Z</dc:date>
    </item>
    <item>
      <title>How to create a variable with n levels based on the size of the data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-variable-with-n-levels-based-on-the-size-of-the/m-p/50761#M13861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Couldn't you just use proc rank .. the data doesn't even have to be sorted.&amp;nbsp; Just specify the number of groups you want. e.g.,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data city;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input city gdp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;1 10&lt;/P&gt;&lt;P&gt;2 9&lt;/P&gt;&lt;P&gt;3 8&lt;/P&gt;&lt;P&gt;4 7&lt;/P&gt;&lt;P&gt;5 6&lt;/P&gt;&lt;P&gt;6 5&lt;/P&gt;&lt;P&gt;7 4&lt;/P&gt;&lt;P&gt;8 3&lt;/P&gt;&lt;P&gt;9 2&lt;/P&gt;&lt;P&gt;10 12&lt;/P&gt;&lt;P&gt;11 13&lt;/P&gt;&lt;P&gt;12 14&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;proc rank data=city groups=4 out=want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; var gdp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ranks gdprank;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2011 18:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-create-a-variable-with-n-levels-based-on-the-size-of-the/m-p/50761#M13861</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-08-18T18:21:33Z</dc:date>
    </item>
  </channel>
</rss>

