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

Hi,

 

I have a data set which contains  product_id's and a number of booleans where each row has  a boolean set to true.

I have multiple rows with the same product_id and each row has different booleans set to true

is there a way to group these rows in to one row per product_id?

 

example 

prod_ID    bool1    bool2      bool3   bool4

A               0           0            1           0

A               0           0            0           1

B               1           0            0           0

B               0           0            0           1

 

I would like to get a date set which looks like

A              0            0             1           1

B              1            0             0           1

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Easily done with proc summary:

data have;
input prod_ID $   bool1    bool2      bool3   bool4;
datalines;
A               0           0            1           0
A               0           0            0           1
B               1           0            0           0
B               0           0            0           1
;

proc summary data=have;
by prod_id;
var bool:;
output out=want (drop=_freq_ _type_) max()=;
run;

View solution in original post

1 REPLY 1
Kurt_Bremser
Super User

Easily done with proc summary:

data have;
input prod_ID $   bool1    bool2      bool3   bool4;
datalines;
A               0           0            1           0
A               0           0            0           1
B               1           0            0           0
B               0           0            0           1
;

proc summary data=have;
by prod_id;
var bool:;
output out=want (drop=_freq_ _type_) max()=;
run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 421 views
  • 1 like
  • 2 in conversation