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

Hi,

I have a macro variable ids, containing the names of my subjects under study.

proc sql noprint;

select distinct(names) into :ids separated by " "

from mytable1;

quit;

how could I use my macro variable ids to create a new column containing the names of my subjects in an other table called mytable2 ? I think I'm looking for an equivalent of symget in proc sql.

Thank you very much

Yohann

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

??

Why not just use the same SQL query to make the new table?

proc sql noprint;

create table new_table as select distinct names

from mytable1;

quit;

View solution in original post

7 REPLIES 7
yomsx
Fluorite | Level 6

Thank you for your answer it's working perfectly,

So I guess it's not possible to do this with a proc sql ?

Tom
Super User Tom
Super User

??

Why not just use the same SQL query to make the new table?

proc sql noprint;

create table new_table as select distinct names

from mytable1;

quit;

yomsx
Fluorite | Level 6

Tom,

I chose a very simple (maybe too simple) example to illustrate a question I was wondering about macro variables in proc sql. I was a bit surprised it was very easy to create a macro variable from a given column of a table but that the inverse operation was not.

Kurt_Bremser
Super User

..but that the inverse operation was not.

It is not necessary, since in SQL you can nest a select within a select.

And create a condition like

where x in (select y from ... where ....)

yomsx
Fluorite | Level 6

I did not think about this proc sql property. Thank you very much for your help

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
  • 7 replies
  • 4187 views
  • 6 likes
  • 3 in conversation