BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GN0001
Barite | Level 11
Combining Data-Sets

data related1;

input Cust1-Cust22 ID;

cards;

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10

run;

data related2;

input ID Cust1-Cust28;

cards;

1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

run;
data notrelatedmatch;
merge related1st(in=in1) related2st(in=in2);
length find $15;
by id;
if in1 and not in2 then find='not_matched1';
else if not in1 and in2 then find='not_matched2';

Hello team,

How to  exclude all variables that begin with “Cu” from notrelatedmatch?

Regards,

blueblue

Blue Blue
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Yes, you can use a list of variables next to DROP=

 

Please go back to your ORIGINAL post in this thread and modify the title to indicate you want to remove variables in a MERGE, so that the title reflects the actual subject of the post.

--
Paige Miller

View solution in original post

9 REPLIES 9
PaigeMiller
Diamond | Level 26

How to  exclude all variables that begin with “Cu” from notrelatedmatch?

 

On the one hand, you ask about removing variables, but your title talks about WHERE clause which removes observations. So which is it? Do you want to remove variables or observations?

--
Paige Miller
GN0001
Barite | Level 11

Hello Diamond,

I am talking about variables. 

I used drop statement:

data notrelatedmatch(drop=cust:);

I got what I wanted. I wonder if we can use a list variable in where clause with not.

 

Please advise me.

Regards,

blueblue

Blue Blue
PaigeMiller
Diamond | Level 26

Yes, you can use a list of variables next to DROP=

 

Please go back to your ORIGINAL post in this thread and modify the title to indicate you want to remove variables in a MERGE, so that the title reflects the actual subject of the post.

--
Paige Miller
ballardw
Super User

@GN0001 wrote:

Hello Diamond,

I am talking about variables. 

I used drop statement:

data notrelatedmatch(drop=cust:);

I got what I wanted. I wonder if we can use a list variable in where clause with not.

 

Please advise me.

Regards,

blueblue


You will have to show the exact where clause you intend to use. Hit or miss whether you guess right. Most value comparisons likely don' t us a list the way you expect, especially if want to compare multiple variables and multiple values.

PaigeMiller
Diamond | Level 26

@GN0001 

 

Please help everyone by editing the title of the ORIGINAL post to indicate that the question is not about WHERE clauses but it is about DROP= lists.

--
Paige Miller
GN0001
Barite | Level 11
Hello,
I did it in the original post.
Regards,
blueblue

Blue Blue
PaigeMiller
Diamond | Level 26

@GN0001 wrote:
Hello,
I did it in the original post.
Regards,
blueblue


I don't think you did, it still says "WHERE clause ..."

--
Paige Miller
GN0001
Barite | Level 11
I did it on the original post. I have been very busy at work and I couldn't
make it to all of them. I think when we do on the original post, the other
titles should be updated as well.

Thanks for all,
blueblue
Blue Blue
ballardw
Super User

Drop cu: ;

 

If you don't want them why bother keeping them through the merge??? Use data set options to Keep=ID as that is the only other variable you show.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 9 replies
  • 2118 views
  • 3 likes
  • 3 in conversation