<?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: Macros warnings and errors in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Macros-warnings-and-errors/m-p/604793#M18421</link>
    <description>Yes, I understand that macro is not necessery in this case. But I really want to have it there. Is it other option to add "rate" without using proc sql?</description>
    <pubDate>Sun, 17 Nov 2019 13:41:51 GMT</pubDate>
    <dc:creator>aaaaa34</dc:creator>
    <dc:date>2019-11-17T13:41:51Z</dc:date>
    <item>
      <title>Macros warnings and errors</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macros-warnings-and-errors/m-p/604785#M18419</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have warning related with my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Firstly, I create datasets. Secondly, I want to choose good values of "univer" variable (only these contain "place" variable). Finally, I want to join these good values with "rate" variable but I don't know how to do this without creating new set- SAS shows:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasWarning focus-line"&gt;&lt;EM&gt;&lt;STRONG&gt;This CREATE TABLE statement recursively references the target table. A consequence of this is a possible data integrity&lt;/STRONG&gt;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV class="sasWarning"&gt;&lt;EM&gt;&lt;STRONG&gt;problem.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data aaa;
input  univer $50. ;
datalines;
wse and 
uww should be chosen 
we dont't have any values 
;
run;
data bbb;
input  place $ rate 1.;
datalines;
wse 8 
uww 8 
eel 9
;
run;
%macro first(data_out=);
%let list_place= wse!uww!ee1;
data xxx_place;
	set aaa;
	%let i_1=1;		
	%do %until (%qscan(&amp;amp;list_place,&amp;amp;i_1,'!') = %str());              
    	%let v1=%scan(&amp;amp;list_place,&amp;amp;i_1,'!');
    		find(univer,"&amp;amp;v1") &amp;gt;0 or
	    %let i_1=%eval(&amp;amp;i_1+1);
	%end;
	choice=1;
run;
proc sql;
create table xxx_place as
  select a.*,b.*
  from xxx_place a inner join bbb b
    on find(a.univer,b.place,'it')
  order by 1,2,3
;
quit;

data &amp;amp;data_out;
set xxx_place;
run;
%mend;

%first(data_out=mydata);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Nov 2019 12:48:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macros-warnings-and-errors/m-p/604785#M18419</guid>
      <dc:creator>aaaaa34</dc:creator>
      <dc:date>2019-11-17T12:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: Macros warnings and errors</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macros-warnings-and-errors/m-p/604792#M18420</link>
      <description>&lt;P&gt;I really don't see the necessity of a macro here, as the sole parameter is used exactly once in the code. A simple %let data_out= would do the same.&lt;/P&gt;
&lt;P&gt;And your WARNING has nothing to do with the macro, it comes from potentially dangerous SQL code. You should not create a table in a select from that same table, create a new table instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table &amp;amp;data_out. as
  select a.*,b.*
  from xxx_place a inner join bbb b
    on find(a.univer,b.place,'it')
  order by 1,2,3
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That way you also don't need the last data step.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Nov 2019 13:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macros-warnings-and-errors/m-p/604792#M18420</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-17T13:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: Macros warnings and errors</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macros-warnings-and-errors/m-p/604793#M18421</link>
      <description>Yes, I understand that macro is not necessery in this case. But I really want to have it there. Is it other option to add "rate" without using proc sql?</description>
      <pubDate>Sun, 17 Nov 2019 13:41:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macros-warnings-and-errors/m-p/604793#M18421</guid>
      <dc:creator>aaaaa34</dc:creator>
      <dc:date>2019-11-17T13:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Macros warnings and errors</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macros-warnings-and-errors/m-p/604812#M18424</link>
      <description>&lt;P&gt;What is the expected result out of your initial two datasets?&lt;/P&gt;</description>
      <pubDate>Sun, 17 Nov 2019 16:37:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macros-warnings-and-errors/m-p/604812#M18424</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-17T16:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macros warnings and errors</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macros-warnings-and-errors/m-p/604814#M18425</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;That's what I want to obtain:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.PNG" style="width: 170px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34036i1765D37174587019/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2.PNG" alt="2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Nov 2019 17:08:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macros-warnings-and-errors/m-p/604814#M18425</guid>
      <dc:creator>aaaaa34</dc:creator>
      <dc:date>2019-11-17T17:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: Macros warnings and errors</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macros-warnings-and-errors/m-p/604890#M18426</link>
      <description>&lt;P&gt;If you want to do a more complex lookup without using SQL, a hash object comes in handy:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data aaa;
input univer $50.;
datalines;
wse and 
uww should be chosen 
we dont't have any values 
;
run;

data bbb;
input place $ rate;
datalines;
wse 8 
uww 5 
eel 9
;
run;

data want;
length
  univer $50
  place $8
  rate 8
;
if _n_ = 1
then do;
  declare hash lookup(dataset:"bbb");
  lookup.definekey("place");
  lookup.definedata("rate");
  lookup.definedone();
end;
call missing(place,rate);
set aaa;
do i = 1 to countw(univer);
  place = scan(univer,i);
  rc = lookup.find();
  put rc= place=;
end;
if rate;
drop rc i place;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Nov 2019 08:03:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macros-warnings-and-errors/m-p/604890#M18426</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-11-18T08:03:24Z</dc:date>
    </item>
  </channel>
</rss>

