<?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: Passing a macro varaible into Proc sql :into statement and them chekcing it with a put in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Passing-a-macro-varaible-into-Proc-sql-into-statement-and-them/m-p/469406#M285505</link>
    <description>&lt;P&gt;Modify pretty much all references to your macro variables.&amp;nbsp; Where you have this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;endsubj;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add another statement first:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let endsubj = &amp;amp;endsubj;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;endsubj;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, change this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;endevt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add a similar statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let endevt = &amp;amp;endevt;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;endevt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then when you use these variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;into : s1-:s%trim(&amp;amp;&amp;amp;endsubj)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change that to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;into : s1-:s&amp;amp;endsubj&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, change this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;s1 &amp;amp;s%trim(&amp;amp;&amp;amp;&amp;amp;endsubj);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change that to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;s1 &amp;amp;&amp;amp;s&amp;amp;endsubj;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, change this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;into : e1-:e&amp;amp;trim(&amp;amp;&amp;amp;endevt)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change it to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;into : e1-e&amp;amp;endevt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, change the final %PUT statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;s1 &amp;amp;s%trim(&amp;amp;&amp;amp;&amp;amp;endevt);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It becomes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;e1 &amp;amp;&amp;amp;e&amp;amp;endevt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Turn on options so you begin to get a feel for what is happening here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options mprint symbolgen;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Jun 2018 21:08:02 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-06-11T21:08:02Z</dc:date>
    <item>
      <title>Passing a macro varaible into Proc sql :into statement and them chekcing it with a put</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-a-macro-varaible-into-Proc-sql-into-statement-and-them/m-p/469399#M285502</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have this code;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;noprint&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; count( &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;distinct&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; TRTN) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;:endsubj &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; subject;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;endsubj;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; count (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;distinct&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; TRT01AN) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;:endevt &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; events;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;endevt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; count(*) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;:s1-:s%&lt;STRONG&gt;&lt;I&gt;trim&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;&amp;amp;endsubj) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;subject &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;group&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; TRTN;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%put&lt;/FONT&gt; &lt;FONT color="#ff0000"&gt;&amp;amp;s1 &amp;amp;s%&lt;STRONG&gt;&lt;I&gt;trim&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;&amp;amp;&amp;amp;endsubj) ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; count(*) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;:e1-:e%&lt;STRONG&gt;&lt;I&gt;trim&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;&amp;amp;endevt) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; events &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;group&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; TRTN;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT size="2"&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color="#0000ff"&gt;%put&lt;/FONT&gt; &lt;FONT color="#ff0000"&gt;&amp;amp;s1 &amp;amp;s%&lt;STRONG&gt;&lt;I&gt;trim&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;&amp;amp;&amp;amp;endevt)&lt;/FONT&gt; ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;quit&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;I get the message for the code in red&amp;nbsp;:&amp;nbsp; WARNING: Apparent symbolic reference S not resolved.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;2 &amp;amp;s&amp;amp; 4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1)Does anyone have a suggestion as to how I should change the syntax to actually&amp;nbsp; the values from S1 to S4 in this case?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a subsequent step I merge the subject and the events datasets to get this the subjects and events by treatment group. into columns&lt;/P&gt;
&lt;P&gt;The dataset columns looks like this .&lt;/P&gt;
&lt;P&gt;s1&amp;nbsp;&amp;nbsp; &amp;nbsp;e1&amp;nbsp;&amp;nbsp; s2&amp;nbsp;&amp;nbsp; e2&amp;nbsp;&amp;nbsp; s3&amp;nbsp;&amp;nbsp; e3&amp;nbsp; &amp;nbsp;s4&amp;nbsp;&amp;nbsp; e4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on the filters used the number of column can increase to 6 (s5 e5 s6 e6).&lt;/P&gt;
&lt;P&gt;My final dataset needs to have all the columns named&amp;nbsp; from f1 to fX.&lt;/P&gt;
&lt;P&gt;2)How can I dynamically do a renaming or assigning of the s and e variables &amp;nbsp;in the final data set:&lt;/P&gt;
&lt;P&gt;f1=s1&amp;nbsp;&amp;nbsp; f2=e1,&amp;nbsp;&amp;nbsp;&amp;nbsp; f3=s2,&amp;nbsp;&amp;nbsp; f4=e2 ,&amp;nbsp; f5=s3, f6=e3 etc...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thx.&lt;/P&gt;
&lt;P&gt;Kc&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 20:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-a-macro-varaible-into-Proc-sql-into-statement-and-them/m-p/469399#M285502</guid>
      <dc:creator>Kc2</dc:creator>
      <dc:date>2018-06-11T20:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a macro varaible into Proc sql :into statement and them chekcing it with a put</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-a-macro-varaible-into-Proc-sql-into-statement-and-them/m-p/469403#M285503</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;

select count( distinct TRTN) into:endsubj from subject;
%put &amp;amp;endsubj;
select count (distinct TRT01AN) into:endevt from events;
%put &amp;amp;endevt;
select count(*) into:s1-:s%trim(&lt;FONT color="#FF0000"&gt;&amp;amp;&lt;/FONT&gt;endsubj) from subject group by TRTN;
%put &amp;amp;s1 &lt;FONT color="#FF0000"&gt;&amp;amp;&amp;amp;&lt;/FONT&gt;s%trim(&lt;FONT color="#FF0000"&gt;&amp;amp;&lt;/FONT&gt;endsubj) ;
select count(*) into:e1-:e%trim(&lt;FONT color="#FF0000"&gt;&amp;amp;&lt;/FONT&gt;endevt) from events group by TRTN;
%put &amp;amp;s1 &lt;FONT color="#FF0000"&gt;&amp;amp;&amp;amp;&lt;/FONT&gt;s%trim(&lt;FONT color="#FF0000"&gt;&amp;amp;&lt;/FONT&gt;endevt) ;

quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your not referencing the macro variables using the ampersand in the right way.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;amp;s%&lt;/SPAN&gt;&lt;STRONG&gt;&lt;I&gt;trim&lt;/I&gt;&lt;/STRONG&gt;&lt;SPAN&gt;(&amp;amp;&amp;amp;&amp;amp;endsubj)&amp;nbsp;--&amp;gt; this will be resolved to (&amp;amp;s)&amp;amp;(&amp;amp;endsubj) the paranthesis values need to be resolved first, there is no macro variable &amp;amp;s referenced so it trowed&amp;nbsp;you error. When you change this to &amp;amp;&amp;amp;s&amp;amp;endsubj then it will resolve (&amp;amp;&amp;amp;s)(&amp;amp;endsubj)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 21:06:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-a-macro-varaible-into-Proc-sql-into-statement-and-them/m-p/469403#M285503</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-06-11T21:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a macro varaible into Proc sql :into statement and them chekcing it with a put</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-a-macro-varaible-into-Proc-sql-into-statement-and-them/m-p/469404#M285504</link>
      <description>&lt;P&gt;Don't do that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS does not need to be told how many macro variables to make.&amp;nbsp; It makes enough to match the data.&lt;/P&gt;
&lt;P&gt;If you need the counts for something else then save the number observations your query generated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select count(*) into :s1- from subject group by TRTN;
%let subject_treatments=&amp;amp;sqlobs;

select count(*) into :e1- from events group by TRTN;
%let event_treatments=&amp;amp;sqlobs;

quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are running a really OOOOOLD version of SAS that does not support that syntax then just some value larger than you could ever need for the upper bound.&amp;nbsp; SAS will still only create the number of macro variables that match the number of levels of TRTN.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select count(*) into :s1-:s10000 from subject group by TRTN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jun 2018 21:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-a-macro-varaible-into-Proc-sql-into-statement-and-them/m-p/469404#M285504</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-11T21:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a macro varaible into Proc sql :into statement and them chekcing it with a put</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-a-macro-varaible-into-Proc-sql-into-statement-and-them/m-p/469406#M285505</link>
      <description>&lt;P&gt;Modify pretty much all references to your macro variables.&amp;nbsp; Where you have this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;endsubj;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add another statement first:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let endsubj = &amp;amp;endsubj;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;endsubj;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, change this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;endevt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add a similar statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let endevt = &amp;amp;endevt;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;endevt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then when you use these variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;into : s1-:s%trim(&amp;amp;&amp;amp;endsubj)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change that to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;into : s1-:s&amp;amp;endsubj&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, change this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;s1 &amp;amp;s%trim(&amp;amp;&amp;amp;&amp;amp;endsubj);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change that to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;s1 &amp;amp;&amp;amp;s&amp;amp;endsubj;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, change this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;into : e1-:e&amp;amp;trim(&amp;amp;&amp;amp;endevt)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change it to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;into : e1-e&amp;amp;endevt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, change the final %PUT statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;s1 &amp;amp;s%trim(&amp;amp;&amp;amp;&amp;amp;endevt);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It becomes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;e1 &amp;amp;&amp;amp;e&amp;amp;endevt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Turn on options so you begin to get a feel for what is happening here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options mprint symbolgen;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jun 2018 21:08:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-a-macro-varaible-into-Proc-sql-into-statement-and-them/m-p/469406#M285505</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-06-11T21:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a macro varaible into Proc sql :into statement and them chekcing it with a put</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-a-macro-varaible-into-Proc-sql-into-statement-and-them/m-p/469478#M285506</link>
      <description>&lt;P&gt;Thanks Tom,&lt;/P&gt;
&lt;P&gt;it solves question 1 .&lt;/P&gt;
&lt;P&gt;But I am still stuck for question 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now that I have the values assigned to macro variables macro variable, I want to rename them dynamically.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question &amp;nbsp;2&lt;/P&gt;
&lt;P&gt;In a subsequent step I merge the subject and the events datasets to get this the subjects and events by treatment group into columns&lt;/P&gt;
&lt;P&gt;The dataset columns looks like this .&lt;/P&gt;
&lt;P&gt;s1&amp;nbsp;&amp;nbsp; &amp;nbsp;e1&amp;nbsp;&amp;nbsp; s2&amp;nbsp;&amp;nbsp; e2&amp;nbsp;&amp;nbsp; s3&amp;nbsp;&amp;nbsp; e3&amp;nbsp; &amp;nbsp;s4&amp;nbsp;&amp;nbsp; e4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on the filters used the number of column can increase to 6 (s5 e5 s6 e6).&lt;/P&gt;
&lt;P&gt;My final dataset needs to have all the columns named&amp;nbsp; from f1 to fX.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2)How can I dynamically do a renaming or assigning of the s and e variables &amp;nbsp;in the final data set:&lt;/P&gt;
&lt;P&gt;f1=s1&amp;nbsp;&amp;nbsp; f2=e1,&amp;nbsp;&amp;nbsp;&amp;nbsp; f3=s2,&amp;nbsp;&amp;nbsp; f4=e2 ,&amp;nbsp; f5=s3, f6=e3 etc...&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 00:49:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-a-macro-varaible-into-Proc-sql-into-statement-and-them/m-p/469478#M285506</guid>
      <dc:creator>Kc2</dc:creator>
      <dc:date>2018-06-12T00:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a macro varaible into Proc sql :into statement and them chekcing it with a put</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-a-macro-varaible-into-Proc-sql-into-statement-and-them/m-p/469487#M285507</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3443"&gt;@Kc2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks Tom,&lt;/P&gt;
&lt;P&gt;it solves question 1 .&lt;/P&gt;
&lt;P&gt;But I am still stuck for question 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now that I have the values assigned to macro variables macro variable, I want to rename them dynamically.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question &amp;nbsp;2&lt;/P&gt;
&lt;P&gt;In a subsequent step I merge the subject and the events datasets to get this the subjects and events by treatment group into columns&lt;/P&gt;
&lt;P&gt;The dataset columns looks like this .&lt;/P&gt;
&lt;P&gt;s1&amp;nbsp;&amp;nbsp; &amp;nbsp;e1&amp;nbsp;&amp;nbsp; s2&amp;nbsp;&amp;nbsp; e2&amp;nbsp;&amp;nbsp; s3&amp;nbsp;&amp;nbsp; e3&amp;nbsp; &amp;nbsp;s4&amp;nbsp;&amp;nbsp; e4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on the filters used the number of column can increase to 6 (s5 e5 s6 e6).&lt;/P&gt;
&lt;P&gt;My final dataset needs to have all the columns named&amp;nbsp; from f1 to fX.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2)How can I dynamically do a renaming or assigning of the s and e variables &amp;nbsp;in the final data set:&lt;/P&gt;
&lt;P&gt;f1=s1&amp;nbsp;&amp;nbsp; f2=e1,&amp;nbsp;&amp;nbsp;&amp;nbsp; f3=s2,&amp;nbsp;&amp;nbsp; f4=e2 ,&amp;nbsp; f5=s3, f6=e3 etc...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you need datasets then do not generate macro variables at all.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
create table subject_count as
select trtn,count(*) as n_subjects
from subjects
group by 1
order by 1
;
create table event_count as
select trtn,count(*) as n_events
from events
group by 1
order by 1
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you need the counts into multiple variables instead of observations then use PROC TRANSPOSE.&lt;/P&gt;
&lt;P&gt;But do you even need a dataset with the counts in columns?&amp;nbsp; Or are are you just talking about a report your need to produce?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 02:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-a-macro-varaible-into-Proc-sql-into-statement-and-them/m-p/469487#M285507</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-12T02:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Passing a macro varaible into Proc sql :into statement and them chekcing it with a put</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Passing-a-macro-varaible-into-Proc-sql-into-statement-and-them/m-p/469584#M285508</link>
      <description>&lt;P&gt;it is for a report. Once I have the columns in a&amp;nbsp; certain&amp;nbsp;order I need to do some processing and them generate a report.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 11:41:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Passing-a-macro-varaible-into-Proc-sql-into-statement-and-them/m-p/469584#M285508</guid>
      <dc:creator>Kc2</dc:creator>
      <dc:date>2018-06-12T11:41:38Z</dc:date>
    </item>
  </channel>
</rss>

