<?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: Make a new table from an existing table in a DATA step. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Make-a-new-table-from-an-existing-table-in-a-DATA-step/m-p/75600#M16294</link>
    <description>sum() is better of course.&lt;BR /&gt;
&lt;BR /&gt;
Rank your records, can be done using a new variable (rank) that gets the value of population for every record except your own country record which get population = -1&lt;BR /&gt;
&lt;BR /&gt;
Sort data by rank...&lt;BR /&gt;
&lt;BR /&gt;
!?</description>
    <pubDate>Thu, 26 Feb 2009 15:58:56 GMT</pubDate>
    <dc:creator>FredrikE</dc:creator>
    <dc:date>2009-02-26T15:58:56Z</dc:date>
    <item>
      <title>Make a new table from an existing table in a DATA step.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-a-new-table-from-an-existing-table-in-a-DATA-step/m-p/75596#M16290</link>
      <description>I have a SAS-table, Population1, that looks like this:&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;Nation Gender Number&lt;/B&gt;&lt;BR /&gt;
Germany Men 41000000&lt;BR /&gt;
Germany Women 42000000&lt;BR /&gt;
France Men 31000000&lt;BR /&gt;
France Women 31500000&lt;BR /&gt;
&lt;BR /&gt;
I would like to make a new SAS-table, Population2, based on Population1. It should look like this:&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;Nation Population Men Women&lt;/B&gt;&lt;BR /&gt;
Germany 83000000 41000000 42000000&lt;BR /&gt;
France 61500000 31000000 315000000&lt;BR /&gt;
&lt;BR /&gt;
Shouldn't it be possible to use the DATA step, starting like this:&lt;BR /&gt;
&lt;BR /&gt;
DATA Population2;&lt;BR /&gt;
set Population1;&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
?&lt;BR /&gt;
&lt;BR /&gt;
But then I would have to get rid of one row for each nation. I have some problems with that. Any better way?&lt;BR /&gt;
&lt;BR /&gt;
Susan</description>
      <pubDate>Thu, 26 Feb 2009 11:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-a-new-table-from-an-existing-table-in-a-DATA-step/m-p/75596#M16290</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-26T11:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Make a new table from an existing table in a DATA step.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-a-new-table-from-an-existing-table-in-a-DATA-step/m-p/75597#M16291</link>
      <description>Try this:&lt;BR /&gt;
&lt;BR /&gt;
proc sort data = population1;&lt;BR /&gt;
 by nation;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc transpose data = population1 out = population2(drop=_name_);&lt;BR /&gt;
 by nation;&lt;BR /&gt;
 id gender;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data population2;&lt;BR /&gt;
 retain nation population men women;&lt;BR /&gt;
 set population2;&lt;BR /&gt;
 length population 8;&lt;BR /&gt;
 population = men + women;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
//Fredrik</description>
      <pubDate>Thu, 26 Feb 2009 12:19:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-a-new-table-from-an-existing-table-in-a-DATA-step/m-p/75597#M16291</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2009-02-26T12:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: Make a new table from an existing table in a DATA step.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-a-new-table-from-an-existing-table-in-a-DATA-step/m-p/75598#M16292</link>
      <description>May be you use:&lt;BR /&gt;
population = sum(men,women);&lt;BR /&gt;
&lt;BR /&gt;
reason: &lt;BR /&gt;
a+b: if a or b is Missing the result will be Missing&lt;BR /&gt;
sum(a,b): Missings values are ignored, sum(a,&lt;MISSING&gt;) resolves to value of a&lt;/MISSING&gt;</description>
      <pubDate>Thu, 26 Feb 2009 13:26:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-a-new-table-from-an-existing-table-in-a-DATA-step/m-p/75598#M16292</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2009-02-26T13:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Make a new table from an existing table in a DATA step.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-a-new-table-from-an-existing-table-in-a-DATA-step/m-p/75599#M16293</link>
      <description>Thanks!&lt;BR /&gt;
&lt;BR /&gt;
But if I woluld like to have the nations sorted, in descending order, by the new variable Population, &lt;B&gt;with one exception:&lt;/B&gt; the number of my own countrys population should be placed last, with no regard to if that number would be greater than some of the numbers above. &lt;BR /&gt;
&lt;BR /&gt;
Do you have any idea?</description>
      <pubDate>Thu, 26 Feb 2009 13:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-a-new-table-from-an-existing-table-in-a-DATA-step/m-p/75599#M16293</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-26T13:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Make a new table from an existing table in a DATA step.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-a-new-table-from-an-existing-table-in-a-DATA-step/m-p/75600#M16294</link>
      <description>sum() is better of course.&lt;BR /&gt;
&lt;BR /&gt;
Rank your records, can be done using a new variable (rank) that gets the value of population for every record except your own country record which get population = -1&lt;BR /&gt;
&lt;BR /&gt;
Sort data by rank...&lt;BR /&gt;
&lt;BR /&gt;
!?</description>
      <pubDate>Thu, 26 Feb 2009 15:58:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-a-new-table-from-an-existing-table-in-a-DATA-step/m-p/75600#M16294</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2009-02-26T15:58:56Z</dc:date>
    </item>
  </channel>
</rss>

