<?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 combining columns and renaming them in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/combining-columns-and-renaming-them/m-p/68714#M19680</link>
    <description>Hello,&lt;BR /&gt;
I know this is simple but I'm a new grad student and trying to get this to work.&lt;BR /&gt;
&lt;BR /&gt;
I have data formatted like this:&lt;BR /&gt;
LOC   FISHID   PREY   AMT&lt;BR /&gt;
1          1         1         3&lt;BR /&gt;
1          1         2         30&lt;BR /&gt;
1          1         3         9&lt;BR /&gt;
1          1         4         12&lt;BR /&gt;
1          2         4         6&lt;BR /&gt;
1          2         6         1&lt;BR /&gt;
&lt;BR /&gt;
I would like to combine the totals for things like prey items 2 and 3 into one total named something like "worms".   And then say name prey items 4 through 11 "fish" and so on.&lt;BR /&gt;
1          1         beetles         3&lt;BR /&gt;
1          1         Worms         39&lt;BR /&gt;
1          1         fish              3&lt;BR /&gt;
1          2         fish              7&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The format for the names would need to be kept as later in the coding i have a proc transform to get a single line per fish with prey turned into columns. &lt;BR /&gt;
EX:&lt;BR /&gt;
Loc     Fishid     Beetles   Worms   Fish&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
So How do do the first transformation so that the second one works?&lt;BR /&gt;
Thanks so much for any help.</description>
    <pubDate>Thu, 03 Feb 2011 17:46:48 GMT</pubDate>
    <dc:creator>ahappel</dc:creator>
    <dc:date>2011-02-03T17:46:48Z</dc:date>
    <item>
      <title>combining columns and renaming them</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/combining-columns-and-renaming-them/m-p/68714#M19680</link>
      <description>Hello,&lt;BR /&gt;
I know this is simple but I'm a new grad student and trying to get this to work.&lt;BR /&gt;
&lt;BR /&gt;
I have data formatted like this:&lt;BR /&gt;
LOC   FISHID   PREY   AMT&lt;BR /&gt;
1          1         1         3&lt;BR /&gt;
1          1         2         30&lt;BR /&gt;
1          1         3         9&lt;BR /&gt;
1          1         4         12&lt;BR /&gt;
1          2         4         6&lt;BR /&gt;
1          2         6         1&lt;BR /&gt;
&lt;BR /&gt;
I would like to combine the totals for things like prey items 2 and 3 into one total named something like "worms".   And then say name prey items 4 through 11 "fish" and so on.&lt;BR /&gt;
1          1         beetles         3&lt;BR /&gt;
1          1         Worms         39&lt;BR /&gt;
1          1         fish              3&lt;BR /&gt;
1          2         fish              7&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The format for the names would need to be kept as later in the coding i have a proc transform to get a single line per fish with prey turned into columns. &lt;BR /&gt;
EX:&lt;BR /&gt;
Loc     Fishid     Beetles   Worms   Fish&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
So How do do the first transformation so that the second one works?&lt;BR /&gt;
Thanks so much for any help.</description>
      <pubDate>Thu, 03 Feb 2011 17:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/combining-columns-and-renaming-them/m-p/68714#M19680</guid>
      <dc:creator>ahappel</dc:creator>
      <dc:date>2011-02-03T17:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: combining columns and renaming them</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/combining-columns-and-renaming-them/m-p/68715#M19681</link>
      <description>Look at using a combination of MERGE with a BY statement and also PROC TRANSPOSE with ID and IDLABEL.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 03 Feb 2011 18:25:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/combining-columns-and-renaming-them/m-p/68715#M19681</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-02-03T18:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: combining columns and renaming them</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/combining-columns-and-renaming-them/m-p/68716#M19682</link>
      <description>hello,&lt;BR /&gt;
&lt;BR /&gt;
&lt;P&gt;if i understood correctly you can use proc format to "label" the prey variable&lt;BR /&gt;
and then the means procedure to get the output data set:&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
DATA A;&lt;BR /&gt;
INPUT LOC FISHID PREY AMT;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 1 1 3&lt;BR /&gt;
1 1 2 30&lt;BR /&gt;
1 1 3 9&lt;BR /&gt;
1 1 4 12&lt;BR /&gt;
1 2 4 6&lt;BR /&gt;
1 2 6 1&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
proc format;&lt;BR /&gt;
	value name&lt;BR /&gt;
		1='beetles'&lt;BR /&gt;
		2-3='Worms'&lt;BR /&gt;
		4-11='fish';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc means data=a noprint nway;&lt;BR /&gt;
class loc fishid prey;&lt;BR /&gt;
var amt;&lt;BR /&gt;
output out=a1 (drop=_type_) sum=;&lt;BR /&gt;
format prey name.;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;P&gt;Marius&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2011 09:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/combining-columns-and-renaming-them/m-p/68716#M19682</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-04T09:20:29Z</dc:date>
    </item>
  </channel>
</rss>

