BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ZacLopresti
Obsidian | Level 7

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_TEXTRAM01_SUMRAM02_SUM
Alarm1236198
Alarm24947
Alarm3.9
Alarm41

.

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ZacLopresti
Obsidian | Level 7

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

View solution in original post

6 REPLIES 6
ChrisNZ
Tourmaline | Level 20

Like this?

proc tabulate;

  class ALARM MACHINE;

  var SUM;

  table ALARM=' ', MACHINE=' '*SUM=' '*sum=' '/box='Alarm';

run;

ZacLopresti
Obsidian | Level 7

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

SASKiwi
PROC Star

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;
ZacLopresti
Obsidian | Level 7
Thanks, works well
ghosh
Barite | Level 11
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;

ghosh_0-1626275617360.png

 

ZacLopresti
Obsidian | Level 7
Thanks. Look good

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1137 views
  • 0 likes
  • 4 in conversation