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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1431 views
  • 1 like
  • 2 in conversation