<?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: Nested Looping Frustrations - I just can't see it! in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277163#M58731</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest you get your ideas together, and then post one question stating what the input data is, and what it needs to do, as I mentione din the other post. &amp;nbsp;The reason is you are mixing various bits of code, doing looping unecessarily. &amp;nbsp;So far, none of the code posted makes any sense, so its likely your vastly over complicating the task.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jun 2016 08:49:02 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-06-14T08:49:02Z</dc:date>
    <item>
      <title>Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277055#M58711</link>
      <description>&lt;P&gt;Just when I thought I had my nested looping problems solved I figured out it wasn't working the way I thought. I'm hoping for some help on structuring a sample program. I need to loop thru each ZIP5 record from the SampledZips dataset. And for each ZIP5 I also need to loop thru each Rule_Order in the QueryRules dataset and do various processing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me with this type of Nest Loop structure? &amp;nbsp;If I can see an example I'm pretty sure I'd be able to build on it. &amp;nbsp;Any examples would appreciated more than you could know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data SampledZips;&lt;BR /&gt;input zip5 $;&lt;BR /&gt;datalines;&lt;BR /&gt;00926&lt;BR /&gt;02360&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data QueryRules;&lt;BR /&gt;input &lt;SPAN&gt;rule_order $&lt;/SPAN&gt;&lt;BR /&gt;datalines;&lt;BR /&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 22:39:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277055#M58711</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-06-13T22:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277056#M58712</link>
      <description>&lt;P&gt;If you need to get information from the two sets together then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; create table want as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; select sampledZips.*, QueryRules.*&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; from sampledZips, QueryRules;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll get a message about a Cartesian join that can't be optimized but that's what you want if every record in the sampledZips is to be combined with every record in the query rules.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 21:53:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277056#M58712</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-06-13T21:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277057#M58713</link>
      <description>&lt;P&gt;But this doesn't help me to do the desired looping, right? &amp;nbsp;Ulitmately I want to do something fancier. &amp;nbsp;This obviously doesn't work, but I was thinking something like this???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Macro MyZips(zip5= );
&amp;nbsp;
Data Want;
for i=1 to (however many RuleOrder records there are) do;
&lt;BR /&gt;     proc sql;&lt;BR /&gt;     create table QueryData&amp;amp;zip5 as &lt;BR /&gt;     select imb_code&lt;BR /&gt;     from scan_table&lt;BR /&gt;     where rule_order = &amp;amp;rule_order&lt;BR /&gt;       and imb_dlvry_zip_5 = &amp;amp;zip5;&lt;BR /&gt;     ); &lt;BR /&gt;     quit;&lt;BR /&gt;end do;
run;
&amp;nbsp;
%mend MyZips;
data _null_;
set SampledZips;
call execute('%MyZips(zip5='||zip5||');');
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 22:33:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277057#M58713</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-06-13T22:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277062#M58714</link>
      <description>&lt;P&gt;If you want to control the actions of the loops through the programming, here's a way. &amp;nbsp;It assumes you have created the two initial data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set sampledZips;&lt;/P&gt;
&lt;P&gt;do _n_=1 to _n_queries_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set queryRules nobs=_n_queries_ point=_n_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;* DO something here;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 22:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277062#M58714</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-13T22:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277063#M58715</link>
      <description>Cool. I don't understand it tho. What is _n_queries_? _n_? nobs=_n_queries_ point=_n_?&lt;BR /&gt;</description>
      <pubDate>Mon, 13 Jun 2016 22:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277063#M58715</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-06-13T22:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277065#M58716</link>
      <description>&lt;P&gt;On the SET statement, a couple of options:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;point= instead of retrieving the very next observation each time, look at the value of _N_ and retrieve that observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;nobs= create a variable holding total number of observations in the data set and, in this case, name it _n_queries_&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 22:39:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277065#M58716</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-13T22:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277066#M58717</link>
      <description>&lt;P&gt;Great. I see the potential with this example. &amp;nbsp;I'll be working on this again tomorrow so I will try to model after this! &amp;nbsp;Stay tuned for more dumb questions. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 22:43:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277066#M58717</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-06-13T22:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277163#M58731</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest you get your ideas together, and then post one question stating what the input data is, and what it needs to do, as I mentione din the other post. &amp;nbsp;The reason is you are mixing various bits of code, doing looping unecessarily. &amp;nbsp;So far, none of the code posted makes any sense, so its likely your vastly over complicating the task.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 08:49:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277163#M58731</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-14T08:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277395#M58751</link>
      <description>&lt;P&gt;Ok, so here's what I'm trying to do inside of the nested loops, but I'm getting an error now saying that there is an Unclosed Do Block. I'm guessing it has to do with the statements I put between the Do and END statements. &amp;nbsp;Ugh. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see I'm trying to make the ZIP5 and Rule variables from the two different datasets and use them to run the same query substituting them in with different values as the program loops. &amp;nbsp;So the query would be run for each Rule of each ZIP5.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Define Oracle libnames ;
libname iv_ora   oracle user=&amp;amp;orauser pass=&amp;amp;orapass path="IVASPRD" schema="IVAS";
libname bids_ora oracle user=exfcread pass="the#Perfect#P1TA" path="IBSCRPRD" schema="IMAPSSCR";

data QueryData;
set sampledZips;
%let zip5=zip5;
do _n_=1 to _n_queries_;
   set QueryRules nobs=_n_queries_ point=_n_;
&lt;BR /&gt;   		%let rule = rule;
		data ods_iv_recon_selected_mp(where=(imb_dlvry_zip_5='&amp;amp;ZIP5'));
		set iv_ora.ods_iv_recon_selected_mp; 
		run;
		data ods_bi_recon_selected_mp (where=(imb_dlvry_zip_5='&amp;amp;ZIP5'));
		set bids_ora.ods_bi_recon_selected_mp; 
		run;

		proc sql;
		create table QueryData%sysfunc(tranwrd(&amp;amp;rule_order,.,_)) as 
			select  DISTINCT %str(%')&amp;amp;analysis_desc.%str(%') as RULE_NM length = 58, 
					a.actual_dlvry_date as AD_DT, 
					a.imb_code length = 31, 
					&amp;amp;rule_order as RULE_ORDER
		    from ods_iv_recon_selected_mp a
	        inner join ods_bi_recon_selected_mp b                                                                                                                                                                                                                                                                                                                                                                                                                                                   
			        on a.imb_code = b.imb_code
			where &amp;amp;RULE;
		quit;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2016 22:03:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277395#M58751</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-06-14T22:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277423#M58754</link>
      <description>&lt;P&gt;I'm torn. &amp;nbsp;On the one hand, you've put together some good pieces of the final program. &amp;nbsp;On the other hand, there are many reasons why this program hasn't a prayer. &amp;nbsp;I'm going to try to redirect your approach, while letting you keep much of what you have done already. &amp;nbsp;Consider this macro (and debug it if necessary ... it's untested):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro loopy;&lt;/P&gt;
&lt;P&gt;%local i j zip5 rule zip_list rule_list;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select zip5 into : zip_list separated by ' ' from sampledzips;&lt;/P&gt;
&lt;P&gt;select rule into : rule_list separated by ' ' from QueryRules;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;%do i=1 %to %sysfunc(countw(&amp;amp;zip_list));&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%let zip5 = %scan(&amp;amp;zip_list, &amp;amp;i);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%do j=1 %to %sysfunc(countw(&amp;amp;rule_list));&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %let rule = %scan(&amp;amp;rule_list, %j);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %put &amp;amp;i &amp;amp;j &amp;amp;zip5 &amp;amp;rule;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%end;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;%mend loopy;&lt;/P&gt;
&lt;P&gt;%loopy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For now, the %PUT statement is just illustrating how the loops work. &amp;nbsp;It gets replaced with two DATA steps and a SQL step (although I'm convinced that a good SQL programmer ... that leaves me out ... could condense this into a single SQL step).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some notes about what you will encounter along the way. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Single quotes suppress all macro processing. &amp;nbsp;So '&amp;amp;ZIP5' will not allow &amp;amp;ZIP5 to resolve. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure where &amp;amp;ANALYSIS_DESC comes from. &amp;nbsp;It looks like it must exist before all this programming occurs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL parses quoted quotes differently, so this will not work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macrostatement"&gt;%str&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;%&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;')&amp;amp;analysis_desc.%str(%'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will have to remove the "quoted" nature of the quotes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macrostatement"&gt;%unquote(%str&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;%&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;')&amp;amp;analysis_desc.%str(%'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;))&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should be enough of a framework that any remaining issues can be worked out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 02:19:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277423#M58754</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-15T02:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277430#M58756</link>
      <description>I appreciate your time so much. I'll get to work on this in the morning.&lt;BR /&gt;&lt;BR /&gt;Btw- the reason for each looping, individual query by Rule is that if a record meets the Rule #1 condition then it needs to be excluded from any later rule query. Each record can count toward only the first Rule condition it meets. So I plan to run a query for Rule #1 and then append it to my FinalData ds . Then I plan to apply a Unique index on the Primary Key variable of Imb_code. This will keep records (imb_codes) from later Rules from being appended to FinalData. That's where I'm ultimately headed.&lt;BR /&gt;&lt;BR /&gt;Thanks again. I hope I can take your advice and get this thing running.</description>
      <pubDate>Wed, 15 Jun 2016 02:47:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277430#M58756</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-06-15T02:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277505#M58762</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nope, still not seeing the big picture here. &amp;nbsp;I don't see why a simple conbine of the two datasets, and then generate some code would not work? &amp;nbsp;What is the purpose of creating X amount of datasets for each loop as well, that doesn't seem to be an efficient way of working - it then means all your further code has to account for lots of datasets - extra work. &amp;nbsp;As I say above collect your thoughts, what are the input datasets (all of them - examples) and what the output should look like. &amp;nbsp;Me, I would create a set of flags in the one dataset for each "test", and then you only have one dataset to work with and selectable flags, but as I mention it is very hard to provide anything as we are only seeing bits and pieces.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 08:26:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277505#M58762</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-15T08:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277643#M58774</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works for me, but not inside an Rsubmit block. &amp;nbsp;Very stange.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277643#M58774</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-06-15T20:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277671#M58775</link>
      <description>&lt;P&gt;There can be issues with a macro variable's value being created on one side (local vs. remote) needing to be transferred to the other side.&amp;nbsp; There are tools to deal with that ... I think they are %SYSLPUT and %SYSLGET but I use this so rarely that I'm not really sure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there's a different issue, it might help to share the log.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:35:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277671#M58775</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-15T20:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277684#M58777</link>
      <description>&lt;P&gt;My Rule variable values can look like these two examples. &amp;nbsp;I think that is causing problems with the macro resolution. ZIP5's look fine, but Rule gets messed up maybe because it has special characters or spaces. &amp;nbsp;I don't undertand what is happening. &amp;nbsp;Can you take a look?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Two Rule Examples:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;A.ACTUAL_DLVRY_DATE &amp;gt; B.ACTUAL_DLVRY_DATE 
A.ACTUAL_DLVRY_DATE IS NULL AND B.ACTUAL_DLVRY_DATE IS NOT NULL &lt;SPAN style="font-family: HelevticaNeue-light, 'Helvetica Neue', Helvetica, Arial, sans-serif; line-height: 20px; background-color: #ffffff;"&gt;Do I need to handle a multi word value like this in the code. &amp;nbsp;Does it have to be quoted somehow?&lt;/SPAN&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select zip5 into : zip_list separated by ' ' from sampledzips;
select rule into : rule_list separated by ' ' from QueryRules;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'm getting weird macro resolutions like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SYMBOLGEN:  Macro variable ZIP_LIST resolves to 00926 02360
MLOGIC(LOOPY):  %DO loop beginning; index variable I; start value is 1; stop value is 2; by value is 1.
MLOGIC(LOOPY):  %LET (variable name is ZIP5)
SYMBOLGEN:  Macro variable ZIP_LIST resolves to 00926 02360
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable RULE_LIST resolves to A.ACTUAL_DLVRY_DATE &amp;gt; B.ACTUAL_DLVRY_DATE A.ACTUAL_DLVRY_DATE IS NULL AND
            B.ACTUAL_DLVRY_DATE IS NOT NULL
MLOGIC(LOOPY):  %DO loop beginning; index variable J; start value is 1; stop value is 15; by value is 1.
MLOGIC(LOOPY):  %LET (variable name is RULE)
SYMBOLGEN:  Macro variable RULE_LIST resolves to A.ACTUAL_DLVRY_DATE &amp;gt; B.ACTUAL_DLVRY_DATE A.ACTUAL_DLVRY_DATE IS NULL AND
            B.ACTUAL_DLVRY_DATE IS NOT NULL
SYMBOLGEN:  Macro variable J resolves to 1
MLOGIC(LOOPY):  %PUT &amp;amp;i &amp;amp;j &amp;amp;zip5 &amp;amp;rule &amp;amp;rule_order &amp;amp;analysis_desc
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable J resolves to 1
SYMBOLGEN:  Macro variable ZIP5 resolves to 00926
SYMBOLGEN:  Macro variable RULE resolves to A
1 1 00926 A
MLOGIC(LOOPY):  %DO loop index variable J is now 2; loop will iterate again.
MLOGIC(LOOPY):  %LET (variable name is RULE)
SYMBOLGEN:  Macro variable RULE_LIST resolves to A.ACTUAL_DLVRY_DATE &amp;gt; B.ACTUAL_DLVRY_DATE A.ACTUAL_DLVRY_DATE IS NULL AND
            B.ACTUAL_DLVRY_DATE IS NOT NULL
SYMBOLGEN:  Macro variable J resolves to 2
MLOGIC(LOOPY):  %PUT &amp;amp;i &amp;amp;j &amp;amp;zip5 &amp;amp;rule &amp;amp;rule_order &amp;amp;analysis_desc
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable J resolves to 2
SYMBOLGEN:  Macro variable ZIP5 resolves to 00926
SYMBOLGEN:  Macro variable RULE resolves to ACTUAL_DLVRY_DATE
1 2 00926 ACTUAL_DLVRY_DATE&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 21:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277684#M58777</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-06-15T21:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277893#M58789</link>
      <description>&lt;P&gt;Got it!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro loopy;
%local i j zip5 rule zip_list rule_list rule_order rule_order_list analysis_desc analysis_desc_list;

proc sql;
select trim(zip5) into : zip_list separated by '#' from sampledzips;
select trim(rule) into : rule_list separated by '#' from QueryRules;
select put(rule_order,3.1) into : rule_order_list separated by '#' from QueryRules;
select trim(analysis_desc) into : analysis_desc_list separated by '#' from QueryRules;
quit;

%do i=1 %to %sysfunc(countw(&amp;amp;zip_list,'#'));
   %let zip5 = %scan(&amp;amp;zip_list, &amp;amp;i,'#');

   %do j=1 %to %sysfunc(countw(&amp;amp;rule_list,'#'));
      %let rule = %scan(&amp;amp;rule_list, &amp;amp;j,'#');
      %let rule_order = %scan(&amp;amp;rule_order_list, &amp;amp;j,'#');
      %let analysis_desc = %scan(&amp;amp;analysis_desc_list, &amp;amp;j,'#');

      %put VARIABLES: &amp;amp;i &amp;amp;j &amp;amp;zip5 &amp;amp;rule &amp;amp;rule_order &amp;amp;analysis_desc;

   %end;
%end;
%mend loopy;
%loopy;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: The PROCEDURE SQL printed pages 1-4.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


VARIABLES: 1 1 00926 A.ACTUAL_DLVRY_DATE IS NULL AND B.ACTUAL_DLVRY_DATE IS NOT NULL 1.0 ACTUAL DELIVERY DATE MISSING IN IV
VARIABLES: 1 2 00926 A.ACTUAL_DLVRY_DATE &amp;gt; B.ACTUAL_DLVRY_DATE 1.5 ACTUAL DELIVERY DATE LATER IN IV
VARIABLES: 2 1 02360 A.ACTUAL_DLVRY_DATE IS NULL AND B.ACTUAL_DLVRY_DATE IS NOT NULL 1.0 ACTUAL DELIVERY DATE MISSING IN IV
VARIABLES: 2 2 02360 A.ACTUAL_DLVRY_DATE &amp;gt; B.ACTUAL_DLVRY_DATE 1.5 ACTUAL DELIVERY DATE LATER IN IV&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Jun 2016 13:44:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277893#M58789</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-06-16T13:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Nested Looping Frustrations - I just can't see it!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277894#M58790</link>
      <description>&lt;P&gt;Good job.&amp;nbsp; Notice a small technical detail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro language does not use quotes ... in most cases, it assumes everything is a character string.&amp;nbsp; So you only need # (not '#') as a list of delimiters.&amp;nbsp; When you use '#' instead, that's using both pound signs and single quotes as delimiters.&amp;nbsp; That's unlikely to have an impact, but it's possible.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 13:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Nested-Looping-Frustrations-I-just-can-t-see-it/m-p/277894#M58790</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-16T13:52:07Z</dc:date>
    </item>
  </channel>
</rss>

