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

Hi

I have 3 tables:

 

data table1;
	input String $;
	datalines;
APPLE
BANNANA
ORANGE
PECAN
CITY
;
run;

data table2;
	input id APPLE BANNANA ORANGE WALNUT PECAN ALMOND CITY $;
	datalines;
111 15 2 34 22 10 12 KRA
112 3 33 45 5 33 45 WRO
113 34 78 90 6 67 34 SUW
114 12 43 56 7 89 0 WAW
run;

data table3;
	input id;
datalines;
111
113
114
;
run;

From table 1 need names(string), from table 3 id and result from table 3

 

 

idAPPLEBANNANAORANGEPECANCITY
1111523410KRA
11334789067SUW
11412435689WAW

 

I will be grateful for suggestions.

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
proc sql noprint;
    select string into :names separated by ',' from table1;
quit;
proc sql;
     create table want as select id,&names from table2
     where id in (select distinct id from table3);
quit;
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26
proc sql noprint;
    select string into :names separated by ',' from table1;
quit;
proc sql;
     create table want as select id,&names from table2
     where id in (select distinct id from table3);
quit;
--
Paige Miller
Jacek2
Obsidian | Level 7

Thank You PaigeMiller

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 755 views
  • 1 like
  • 2 in conversation