04-03-2015 05:23 AM
I have a macro variable ids, containing the names of my subjects under study.
proc sql noprint;
select distinct(names) into :ids separated by " "
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
04-03-2015 05:29 AM
i = 1;
do until (scan(ids,i) = ' ');
names = scan(ids,i);
i = i + 1;
04-03-2015 06:30 AM
Maybe someone else could help you out, but I think that is done best in the data step. I can't come up wit a SQL solution.
04-03-2015 08:08 AM
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.
04-03-2015 08:13 AM
..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 ....)
Need further help from the community? Please ask a new question.