<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Add a new column from a macro variable proc sql in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215663#M53076</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Apr 2015 12:08:01 GMT</pubDate>
    <dc:creator>yomsx</dc:creator>
    <dc:date>2015-04-03T12:08:01Z</dc:date>
    <item>
      <title>Add a new column from a macro variable proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215658#M53071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a macro variable ids, containing the names of my subjects under study.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint; &lt;/P&gt;&lt;P&gt;select distinct(names) into :ids separated by " "&lt;/P&gt;&lt;P&gt;from mytable1; &lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yohann&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2015 09:23:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215658#M53071</guid>
      <dc:creator>yomsx</dc:creator>
      <dc:date>2015-04-03T09:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: Add a new column from a macro variable proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215659#M53072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data mytable2;&lt;/P&gt;&lt;P&gt;ids="&amp;amp;ids";&lt;/P&gt;&lt;P&gt;i = 1;&lt;/P&gt;&lt;P&gt;do until (scan(ids,i) = ' ');&lt;/P&gt;&lt;P&gt;&amp;nbsp; names = scan(ids,i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; i = i + 1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2015 09:29:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215659#M53072</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-04-03T09:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: Add a new column from a macro variable proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215660#M53073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your answer it's working perfectly,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I guess it's not possible to do this with a proc sql ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2015 09:36:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215660#M53073</guid>
      <dc:creator>yomsx</dc:creator>
      <dc:date>2015-04-03T09:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: Add a new column from a macro variable proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215661#M53074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2015 10:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215661#M53074</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-04-03T10:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Add a new column from a macro variable proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215662#M53075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;??&lt;/P&gt;&lt;P&gt;Why not just use the same SQL query to make the new table?&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc sql noprint;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;create table new_table as select distinct names&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;from mytable1;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2015 10:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215662#M53075</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-04-03T10:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Add a new column from a macro variable proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215663#M53076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2015 12:08:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215663#M53076</guid>
      <dc:creator>yomsx</dc:creator>
      <dc:date>2015-04-03T12:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Add a new column from a macro variable proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215664#M53077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;..but that the inverse operation was not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is not necessary, since in SQL you can nest a select within a select.&lt;/P&gt;&lt;P&gt;And create a condition like&lt;/P&gt;&lt;P&gt;where x in (select y from ... where ....)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2015 12:13:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215664#M53077</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-04-03T12:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Add a new column from a macro variable proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215665#M53078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did not think about this proc sql property. Thank you very much for your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2015 12:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Add-a-new-column-from-a-macro-variable-proc-sql/m-p/215665#M53078</guid>
      <dc:creator>yomsx</dc:creator>
      <dc:date>2015-04-03T12:23:43Z</dc:date>
    </item>
  </channel>
</rss>

