<?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 Make new variables from existing groups in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Make-new-variables-from-existing-groups/m-p/753984#M237695</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Just need a hand with a simple issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im trying to re conficgure some data for a report.&lt;/P&gt;&lt;P&gt;I've filtered and processed the data down to what I want but now I have to separate the sum for each machine per alarm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A sample of the data is attached.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ALARMS;
   input ALARM_NAME$ MACHINE$ SUM;
   datalines;
Alarm1 RAM01 236
Alarm1 RAM02 198
Alarm2 RAM01 49
Alarm2 RAM02 47
Alarm3 RAM02 9
Alarm4 RAM01 1 
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the final product to look something like the following. I dont mind if the final processing is done i the report step or elsewhere.&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ALARM_TEXT&lt;/TD&gt;&lt;TD&gt;RAM01_SUM&lt;/TD&gt;&lt;TD&gt;RAM02_SUM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Alarm1&lt;/TD&gt;&lt;TD&gt;236&lt;/TD&gt;&lt;TD&gt;198&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Alarm2&lt;/TD&gt;&lt;TD&gt;49&lt;/TD&gt;&lt;TD&gt;47&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Alarm3&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Alarm4&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jul 2021 01:39:26 GMT</pubDate>
    <dc:creator>ZacLopresti</dc:creator>
    <dc:date>2021-07-14T01:39:26Z</dc:date>
    <item>
      <title>Make new variables from existing groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-new-variables-from-existing-groups/m-p/753984#M237695</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Just need a hand with a simple issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im trying to re conficgure some data for a report.&lt;/P&gt;&lt;P&gt;I've filtered and processed the data down to what I want but now I have to separate the sum for each machine per alarm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A sample of the data is attached.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ALARMS;
   input ALARM_NAME$ MACHINE$ SUM;
   datalines;
Alarm1 RAM01 236
Alarm1 RAM02 198
Alarm2 RAM01 49
Alarm2 RAM02 47
Alarm3 RAM02 9
Alarm4 RAM01 1 
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the final product to look something like the following. I dont mind if the final processing is done i the report step or elsewhere.&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ALARM_TEXT&lt;/TD&gt;&lt;TD&gt;RAM01_SUM&lt;/TD&gt;&lt;TD&gt;RAM02_SUM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Alarm1&lt;/TD&gt;&lt;TD&gt;236&lt;/TD&gt;&lt;TD&gt;198&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Alarm2&lt;/TD&gt;&lt;TD&gt;49&lt;/TD&gt;&lt;TD&gt;47&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Alarm3&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Alarm4&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 01:39:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-new-variables-from-existing-groups/m-p/753984#M237695</guid>
      <dc:creator>ZacLopresti</dc:creator>
      <dc:date>2021-07-14T01:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Make new variables from existing groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-new-variables-from-existing-groups/m-p/753986#M237697</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;proc tabulate;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; class ALARM MACHINE;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; var SUM;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; table&amp;nbsp;ALARM=' ', MACHINE=' '*SUM=' '*sum=' '/box='Alarm';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 02:16:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-new-variables-from-existing-groups/m-p/753986#M237697</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-07-14T02:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: Make new variables from existing groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-new-variables-from-existing-groups/m-p/753988#M237699</link>
      <description>&lt;P&gt;Thankyou!&lt;/P&gt;&lt;P&gt;I just had to alter it slightly to get it to work.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ALARMS;
   input ALARM_NAME$ MACHINE$ COUNT;
   datalines;
Alarm1 RAM01 236
Alarm1 RAM02 198
Alarm2 RAM01 49
Alarm2 RAM02 47
Alarm3 RAM02 9
Alarm4 RAM01 1 
;

proc tabulate data=ALARMS;
  class ALARM_NAME MACHINE;
  var COUNT;
  table ALARM_NAME=' ', MACHINE=' '*COUNT=' '/box='Alarm';
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Will have to learn PROC TABULATE.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone has any alternate ways feel free to add.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 02:28:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-new-variables-from-existing-groups/m-p/753988#M237699</guid>
      <dc:creator>ZacLopresti</dc:creator>
      <dc:date>2021-07-14T02:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Make new variables from existing groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-new-variables-from-existing-groups/m-p/753990#M237700</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ALARMS(drop=machine); 
   input ALARM_NAME$ MACHINE$ SUM;
   length tmp_machine $9;
   tmp_machine=cats(machine,'_SUM');
   datalines;
Alarm1 RAM01 236
Alarm1 RAM02 198
Alarm2 RAM01 49
Alarm2 RAM02 47
Alarm3 RAM02 9
Alarm4 RAM01 1 
;
proc transpose 
	data=alarms(rename=(tmp_machine=machine))
	out=want(drop=_name_ ); 
	by ALARM_NAME;
	id MACHINE;
run;
proc print; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ghosh_0-1626275617360.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61248i85653908056CE69F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ghosh_0-1626275617360.png" alt="ghosh_0-1626275617360.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jul 2021 15:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-new-variables-from-existing-groups/m-p/753990#M237700</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2021-07-14T15:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Make new variables from existing groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-new-variables-from-existing-groups/m-p/753995#M237701</link>
      <description>&lt;P&gt;Another way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ALARMS;
   input ALARM_NAME $ MACHINE $ SUM;
   datalines;
Alarm1 RAM01 236
Alarm1 RAM02 198
Alarm2 RAM01 49
Alarm2 RAM02 47
Alarm3 RAM02 9
Alarm4 RAM01 1 
;
run;

proc report data = ALARMS;
  column ALARM_NAME MACHINE, SUM  ;
  define ALARM_NAME / group ;
  define MACHINE / " " across ;
  define SUM / sum "Sum" format = comma16.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Jul 2021 05:02:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-new-variables-from-existing-groups/m-p/753995#M237701</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-07-14T05:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Make new variables from existing groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-new-variables-from-existing-groups/m-p/754210#M237790</link>
      <description>Thanks. Look good</description>
      <pubDate>Thu, 15 Jul 2021 00:08:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-new-variables-from-existing-groups/m-p/754210#M237790</guid>
      <dc:creator>ZacLopresti</dc:creator>
      <dc:date>2021-07-15T00:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Make new variables from existing groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Make-new-variables-from-existing-groups/m-p/754211#M237791</link>
      <description>Thanks, works well</description>
      <pubDate>Thu, 15 Jul 2021 00:08:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Make-new-variables-from-existing-groups/m-p/754211#M237791</guid>
      <dc:creator>ZacLopresti</dc:creator>
      <dc:date>2021-07-15T00:08:40Z</dc:date>
    </item>
  </channel>
</rss>

