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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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