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

I have a large lookup table that has duplicate values. I'm joining this table based on the "code" field to other tables and adding the flag values to the other tables. Obviously in it's current format it is not possible to do because it creates a one to many join. I would like to compress this table while retaining the information in the lookup table. Below is what I have and the data set I'm trying to create (want).

 

data have;
input code flag1 flag2 flag3 flag4;
datalines;
4350 0 0 1 0
4350 1 0 0 0
4456 1 0 0 0
2345 0 0 0 1
1234 0 1 0 0
1234 1 0 0 0
;
run;

data want;
input code flag1 flag2 flag3 flag4;
datalines;
4350 1 0 1 0
4456 1 0 0 0
2345 0 0 0 1
1234 1 1 0 0
;
run;

I know I could break this out and do the joins to the lookup table separately, but because of the size of the tables involved I'm trying to avoid that. Is there a way to do what I'm thinking?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Proc summary data=have nway;

   class code;

   var flag: ;

   output out=want (drop=_:) max=;

run;

 

might do it.

View solution in original post

5 REPLIES 5
ballardw
Super User

Proc summary data=have nway;

   class code;

   var flag: ;

   output out=want (drop=_:) max=;

run;

 

might do it.

PeterClemmensen
Tourmaline | Level 20

Try this

 

proc summary data = have nway;
   class code;
   var flag:;
   output out = want(drop = _:) max =;
run;
ballardw
Super User

@PeterClemmensen wrote:

Try this

 

proc summary data = have nway;
   class code;
   var flag:;
   output out = want(drop = _:) max =;
run;

Looks familiar... 🤔

PeterClemmensen
Tourmaline | Level 20

Shoot, didn't see that!

 

Now I have to come up with another way 😄

ballardw
Super User

@PeterClemmensen wrote:

Shoot, didn't see that!

 

Now I have to come up with another way 😄


Take it as a "great minds" thing.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 743 views
  • 0 likes
  • 3 in conversation