<?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: INTO Statement in PROC SQL to Create Macro Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/INTO-Statement-in-PROC-SQL-to-Create-Macro-Variable/m-p/540661#M149183</link>
    <description>&lt;P&gt;If you need quotes, you have to set them:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data RawData;
length name $10;
input name $;
datalines;
Peter
John
Paul
David
;
run;

proc sql noprint;
select quote(trim(name))
into :namesP separated by ','
from RawData
where substr(name,1,1) = 'P'
;
quit;

%put &amp;amp;namesP;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log excerpt:&lt;/P&gt;
&lt;PRE&gt;46         %put &amp;amp;namesP;
"Peter","Paul"
&lt;/PRE&gt;</description>
    <pubDate>Wed, 06 Mar 2019 06:40:34 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-03-06T06:40:34Z</dc:date>
    <item>
      <title>INTO Statement in PROC SQL to Create Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTO-Statement-in-PROC-SQL-to-Create-Macro-Variable/m-p/540660#M149182</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I am using proc sql with into statement to create SAS Macro Varaible.&lt;/P&gt;
&lt;P&gt;In this example I create a&amp;nbsp; Macro Varaible called nameP that should recieve value &amp;nbsp; "Peter","Paul"&lt;/P&gt;
&lt;P&gt;What is the correct way to get it?&lt;/P&gt;
&lt;P&gt;In the code that I wrote I get value&amp;nbsp;Peter,Paul &amp;nbsp;and then there is an error&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;******INTO Statement in PROC SQL to Create Macro Variables******;
 
data RawData;
length name $10;
input name $;
datalines;
Peter
John
Paul
David
;
run;

/*Solution with error*/
proc sql noprint;
select name
into :namesP separated by ','
from RawData
where substr(name,1,1) = 'P'
;
quit;
%put &amp;amp;namesP;/*Peter,Paul*/

data Outcome;
set RawData;
where name IN (&amp;amp;namesP.);
run;


/*Correct solution*/
%let names="Peter","Paul";
data Outcome;
set RawData;
where name IN (&amp;amp;names.);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Mar 2019 06:37:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTO-Statement-in-PROC-SQL-to-Create-Macro-Variable/m-p/540660#M149182</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-03-06T06:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: INTO Statement in PROC SQL to Create Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INTO-Statement-in-PROC-SQL-to-Create-Macro-Variable/m-p/540661#M149183</link>
      <description>&lt;P&gt;If you need quotes, you have to set them:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data RawData;
length name $10;
input name $;
datalines;
Peter
John
Paul
David
;
run;

proc sql noprint;
select quote(trim(name))
into :namesP separated by ','
from RawData
where substr(name,1,1) = 'P'
;
quit;

%put &amp;amp;namesP;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log excerpt:&lt;/P&gt;
&lt;PRE&gt;46         %put &amp;amp;namesP;
"Peter","Paul"
&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Mar 2019 06:40:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INTO-Statement-in-PROC-SQL-to-Create-Macro-Variable/m-p/540661#M149183</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-06T06:40:34Z</dc:date>
    </item>
  </channel>
</rss>

