BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
miss2223
Fluorite | Level 6

I would like to know who has got Apple and Pear.

Output expecting to see John and Grant only. 

 

Here is my code:

data person;
input name $ products$;
datalines;
John Apple
John Pear
Mary Apple

Helen Apple
Helen Orange
Grant Apple
Grant Pear
;

 

Thanks 

1 ACCEPTED SOLUTION

Accepted Solutions
tarheel13
Rhodochrosite | Level 12
proc sort data=person;
by name;
run;

proc transpose data=person out=person_t(drop=_name_);
by name;
var products;
run;

data person2;
set person_t;
all_prods=catx(',',of col:);
if prxmatch('/Apple,Pear|Pear,Apple/i',all_prods);
run;

 

View solution in original post

2 REPLIES 2
andreas_lds
Jade | Level 19

What have you tried?

Do you want a dataset or a report?

In both cases: use a where statement.

 

tarheel13
Rhodochrosite | Level 12
proc sort data=person;
by name;
run;

proc transpose data=person out=person_t(drop=_name_);
by name;
var products;
run;

data person2;
set person_t;
all_prods=catx(',',of col:);
if prxmatch('/Apple,Pear|Pear,Apple/i',all_prods);
run;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 396 views
  • 0 likes
  • 3 in conversation