<?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: how to put proc sql select into macro variable name in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-put-proc-sql-select-into-macro-variable-name/m-p/760895#M39291</link>
    <description>&lt;P&gt;We are pretty close to what I was looking for.&lt;/P&gt;
&lt;P&gt;As I can see, from your example, it is not with the proc SQL that I have difficulties but with the %put statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried this put statement.&amp;nbsp; Usually, we just need to do %put &amp;amp;=mvar; to get this into the log file: RealDate_je_auto=20210729, but it is not working.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried this&amp;nbsp;%put &amp;amp;&amp;amp;mvar=&amp;amp;&amp;amp;&amp;amp;mvar;&lt;BR /&gt;RealDate_je_auto=20210729&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a better way to obtain&amp;nbsp;RealDate_je_auto=20210729 into the log file.&lt;/P&gt;
&lt;P&gt;Thanks in advance for your help, it is very appreciated.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Aug 2021 12:23:20 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2021-08-11T12:23:20Z</dc:date>
    <item>
      <title>how to put proc sql select into macro variable name</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-put-proc-sql-select-into-macro-variable-name/m-p/760399#M39275</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have using RealDate to put the value of transaction_dt in it.&lt;/P&gt;
&lt;P&gt;But it there a way to replace the name of RealDate by the value of macro variable name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let cie5=wu;&lt;BR /&gt;%let lob2=prop;&lt;/P&gt;
&lt;P&gt;%let name=RealDate_&amp;amp;cie5._&amp;amp;lob2;&lt;BR /&gt;%put &amp;amp;=name.;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql noprint; &lt;BR /&gt;select transaction_dt into : RealDate &lt;BR /&gt;from (select transaction_dt, &lt;BR /&gt;count(transaction_dt) as nobservations &lt;BR /&gt;from srch5.&amp;amp;cie5.&amp;amp;lob2._prm_d&amp;amp;date1. &lt;BR /&gt;group by transaction_dt) &lt;BR /&gt;having nobservations=max(nobservations); &lt;BR /&gt;quit; &lt;BR /&gt;&lt;BR /&gt;%put ===========&amp;gt; &amp;amp;=RealDate;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ex:&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql ;&lt;/P&gt;
&lt;P&gt;select into : &amp;amp;name.&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 15:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-put-proc-sql-select-into-macro-variable-name/m-p/760399#M39275</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2021-08-09T15:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to put proc sql select into macro variable name</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-put-proc-sql-select-into-macro-variable-name/m-p/760400#M39276</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;But it there a way to replace the name of RealDate by the value of macro variable name.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I'm really not understanding the above sentence. Please explain further. Show us what you want in pseudo-code.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 16:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-put-proc-sql-select-into-macro-variable-name/m-p/760400#M39276</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-08-09T16:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to put proc sql select into macro variable name</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-put-proc-sql-select-into-macro-variable-name/m-p/760427#M39277</link>
      <description>&lt;P&gt;Hello, I am sorry for not being clear.&lt;/P&gt;
&lt;P&gt;I will do my best.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you look a the proc sql query below, it put the maximum transaction_dt into RealDate.&amp;nbsp; But if you look at the from statement,&lt;/P&gt;
&lt;P&gt;srch5 is a libname,&amp;nbsp; &amp;amp;cie5, is a macro variable containing a precise company abreviation (ex: Lo for Loyds, and lob2 is a macro variable containing the line of business, prop for property.&lt;/P&gt;
&lt;P&gt;So I would like instead of using Realdate as the macro variable name into the proc sql statement to use something more personnal like RealDate_&amp;amp;cie5._&amp;amp;lob2.&amp;nbsp; so the macro variable name become RealDate_Lo_prop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql noprint; &lt;BR /&gt;select transaction_dt into : RealDate &lt;BR /&gt;from (select transaction_dt, &lt;BR /&gt;count(transaction_dt) as nobservations &lt;BR /&gt;from srch5.&amp;amp;cie5.&amp;amp;lob2._prm_d&amp;amp;date1. &lt;BR /&gt;group by transaction_dt) &lt;BR /&gt;having nobservations=max(nobservations); &lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 17:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-put-proc-sql-select-into-macro-variable-name/m-p/760427#M39277</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2021-08-09T17:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to put proc sql select into macro variable name</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-put-proc-sql-select-into-macro-variable-name/m-p/760430#M39278</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;to use something more personal&amp;nbsp;like RealDate_&amp;amp;cie5._&amp;amp;lob2.&amp;nbsp; so the macro variable name become RealDate_Lo_prop.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;So did you try that?&amp;nbsp; What happened?&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select transaction_dt
  into :RealDate_&amp;amp;cie5._&amp;amp;lob2.
  from 
  ( select transaction_dt
          , count(transaction_dt) as nobservations
   from srch5.&amp;amp;cie5.&amp;amp;lob2._prm_d&amp;amp;date1.
  group by transaction_dt
  )
  having nobservations=max(nobservations)
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;To reference that new name use something like:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;amp;&amp;amp;RealDate_&amp;amp;cie5._&amp;amp;lob2.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Although I find it is often easier to build the name into another macro variable and then use that.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mvar=RealDate_&amp;amp;cie5._&amp;amp;lob2.;
select transaction_dt
  into :&amp;amp;mvar
...
%put &amp;amp;&amp;amp;&amp;amp;mvar;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Aug 2021 17:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-put-proc-sql-select-into-macro-variable-name/m-p/760430#M39278</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-08-09T17:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to put proc sql select into macro variable name</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-put-proc-sql-select-into-macro-variable-name/m-p/760895#M39291</link>
      <description>&lt;P&gt;We are pretty close to what I was looking for.&lt;/P&gt;
&lt;P&gt;As I can see, from your example, it is not with the proc SQL that I have difficulties but with the %put statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried this put statement.&amp;nbsp; Usually, we just need to do %put &amp;amp;=mvar; to get this into the log file: RealDate_je_auto=20210729, but it is not working.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried this&amp;nbsp;%put &amp;amp;&amp;amp;mvar=&amp;amp;&amp;amp;&amp;amp;mvar;&lt;BR /&gt;RealDate_je_auto=20210729&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a better way to obtain&amp;nbsp;RealDate_je_auto=20210729 into the log file.&lt;/P&gt;
&lt;P&gt;Thanks in advance for your help, it is very appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2021 12:23:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-put-proc-sql-select-into-macro-variable-name/m-p/760895#M39291</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2021-08-11T12:23:20Z</dc:date>
    </item>
  </channel>
</rss>

