<?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: Error in macro statement in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Error-in-macro-statement/m-p/603745#M76484</link>
    <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select SCHOOLS, OPINION, COUNTRY
  from AAA
      ,BBB
  where index(SCHOOLS, PLACE, 't' );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Nov 2019 03:17:28 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2019-11-13T03:17:28Z</dc:date>
    <item>
      <title>Error in macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-in-macro-statement/m-p/603349#M76473</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to find only these cases in which "schools" variable has at least one value from "place" variable. Then I want to also add to these cases the right values of "opinion" and "country" variables. Using datasets which I created in SAS (code below) the results should look like:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas2.PNG" style="width: 242px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33846iB759513F1D90C454/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sas2.PNG" alt="sas2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's my code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data aaa;
	input  schools: $50.;
	datalines;
harvard
only_harvard
cheese_cake_pizza
wse_is_for_you
;
proc print data=aaa noobs; 
run;
data bbb;
	input  place: $10. opinion: 2. country: $10.;
    datalines;
harvard 8 usa
oxford 8 uk
wse 9 france
;
%macro xxx(data_out=);
%let listopinion=;
proc sql noprint;
select opinion
into :listopinion separated by "!"
from bbb
;
run;
quit;
%let listcountry=;
proc sql noprint;
select country
into :listcountry separated by "!"
from bbb
;
run;
quit;
%let listplace=;
proc sql noprint;
select place
into :listplace separated by "!"
from bbb
;
run;
quit;
data &amp;amp;data_out;
set 
%let i_1 =1;
%let i_2 =1;
%let i_3 =1;
%do %until (%qscan(&amp;amp;listcountry,&amp;amp;i_3,'!') = %str());
	%do %until (%qscan(&amp;amp;listopinion,&amp;amp;i_2,'!') = %str());
		%do %until (%qscan(&amp;amp;listplace,&amp;amp;i_1,'!') = %str());                
			%let zm1=%scan(&amp;amp;listplace,&amp;amp;i_1,'!');
				find(schools,"&amp;amp;zm1") &amp;gt;0
			%let i_1=%eval(&amp;amp;i_1+1);
		%end;
		%let zm2=%scan(&amp;amp;listopinion,&amp;amp;i_2,'!');
		%let i_2=%eval(&amp;amp;i_2+1);
	%end;
	%let zm3=%scan(&amp;amp;listcountry,&amp;amp;i_3,'!');
    %let i_3=%eval(&amp;amp;i_3+1);
%end;
run;
keep school &amp;amp;zm1 &amp;amp;zm2 &amp;amp;zm3;
%mend;

%xxx(data_out=ddd);&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 21:03:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-in-macro-statement/m-p/603349#M76473</guid>
      <dc:creator>ab97_cd</dc:creator>
      <dc:date>2019-11-11T21:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Error in macro statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-in-macro-statement/m-p/603745#M76484</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select SCHOOLS, OPINION, COUNTRY
  from AAA
      ,BBB
  where index(SCHOOLS, PLACE, 't' );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Nov 2019 03:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-in-macro-statement/m-p/603745#M76484</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-11-13T03:17:28Z</dc:date>
    </item>
  </channel>
</rss>

