Hi all,
Just need a hand with a simple issue.
Im trying to re conficgure some data for a report.
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.
A sample of the data is attached.
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
;
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.
ALARM_TEXT | RAM01_SUM | RAM02_SUM |
Alarm1 | 236 | 198 |
Alarm2 | 49 | 47 |
Alarm3 | . | 9 |
Alarm4 | 1 | . |
Thanks
Thankyou!
I just had to alter it slightly to get it to work.
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;
Will have to learn PROC TABULATE.
If anyone has any alternate ways feel free to add.
Thanks
Like this?
proc tabulate;
class ALARM MACHINE;
var SUM;
table ALARM=' ', MACHINE=' '*SUM=' '*sum=' '/box='Alarm';
run;
Thankyou!
I just had to alter it slightly to get it to work.
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;
Will have to learn PROC TABULATE.
If anyone has any alternate ways feel free to add.
Thanks
Another way:
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;
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;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.