<?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: Problem in Macro Loops , Macro Scope in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73423#M15815</link>
    <description>@cakcan: I honestly don't know what you are trying to do. I get the vague sense that you are trying to compare an observation against another. See if below makes any sense to you. &lt;BR /&gt;
&lt;BR /&gt;
The output has all the combination of each observation (whose obs number indicated by i) compared against another (j), including itself. Given the pair of observations, then each of the three variables are compared: first var of the ith obs compared against the first var of the jth obs, and so on. &lt;BR /&gt;
&lt;BR /&gt;
The results of the comparisons are simply summarized by the code variable, where 1 means match and 0 means no-match. For instance, the code value of 100 indicates that the first variable value of the ith observation matched with the first variable value of the jth observation, but the second and the third variable values did not. Then using a format, the code is translated into type. Hope this helps a bit.&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
/* test data */&lt;BR /&gt;
data one;&lt;BR /&gt;
  input i (i1 i2 i3) (:$1.);&lt;BR /&gt;
cards;&lt;BR /&gt;
1 A B C&lt;BR /&gt;
2 A B D&lt;BR /&gt;
3 X B C&lt;BR /&gt;
4 X B Y&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* full join by itself */&lt;BR /&gt;
data two;&lt;BR /&gt;
  set one nobs=nobs;&lt;BR /&gt;
  do point = 1 to nobs;&lt;BR /&gt;
    set one(rename=(i=j i1=j1 i2=j2 i3=j3)) point=point;&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* generate type */&lt;BR /&gt;
proc format;&lt;BR /&gt;
  value $type &lt;BR /&gt;
    "111" = "line extention"&lt;BR /&gt;
    "110" = "brand extension"&lt;BR /&gt;
    "011" = "new category to brand"&lt;BR /&gt;
    "010" = "new brand"&lt;BR /&gt;
    other = "blank";&lt;BR /&gt;
run;&lt;BR /&gt;
data three;&lt;BR /&gt;
  set two;&lt;BR /&gt;
  code = cats(i1=j1, i2=j2, i3=j3);&lt;BR /&gt;
  type = put(code,$type21.);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* check */&lt;BR /&gt;
proc print data=three noobs;&lt;BR /&gt;
  var i j code type;&lt;BR /&gt;
run;&lt;BR /&gt;
/* on lst&lt;BR /&gt;
i    j    code    type&lt;BR /&gt;
&lt;BR /&gt;
1    1    111     line extention&lt;BR /&gt;
1    2    110     brand extension&lt;BR /&gt;
1    3    011     new category to brand&lt;BR /&gt;
1    4    010     new brand&lt;BR /&gt;
2    1    110     brand extension&lt;BR /&gt;
2    2    111     line extention&lt;BR /&gt;
2    3    010     new brand&lt;BR /&gt;
2    4    010     new brand&lt;BR /&gt;
3    1    011     new category to brand&lt;BR /&gt;
3    2    010     new brand&lt;BR /&gt;
3    3    111     line extention&lt;BR /&gt;
3    4    110     brand extension&lt;BR /&gt;
4    1    010     new brand&lt;BR /&gt;
4    2    010     new brand&lt;BR /&gt;
4    3    110     brand extension&lt;BR /&gt;
4    4    111     line extention&lt;BR /&gt;
*/&lt;BR /&gt;
[/pre]</description>
    <pubDate>Mon, 20 Sep 2010 20:25:04 GMT</pubDate>
    <dc:creator>chang_y_chung_hotmail_com</dc:creator>
    <dc:date>2010-09-20T20:25:04Z</dc:date>
    <item>
      <title>Problem in Macro Loops , Macro Scope</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73421#M15813</link>
      <description>%macro test1;&lt;BR /&gt;
&lt;BR /&gt;
data libcan.q9;&lt;BR /&gt;
set libcan.hoppalason;&lt;BR /&gt;
&lt;BR /&gt;
%do i=1 %to 10;&lt;BR /&gt;
		%global &amp;amp;&amp;amp;skodf&amp;amp;i;&lt;BR /&gt;
		%global &amp;amp;&amp;amp;char2f&amp;amp;i;&lt;BR /&gt;
		%global &amp;amp;&amp;amp;char3f&amp;amp;i;&lt;BR /&gt;
		/*%global &amp;amp;&amp;amp;ilkdonemf&amp;amp;i;*/&lt;BR /&gt;
%end;&lt;BR /&gt;
&lt;BR /&gt;
%let ncan=10; &lt;BR /&gt;
&lt;BR /&gt;
%do i=1 %to 10;&lt;BR /&gt;
&lt;BR /&gt;
		if _n_=&amp;amp;i then call symputx("skodf&amp;amp;i",skod);&lt;BR /&gt;
		if _n_=&amp;amp;i then call symputx("char2f&amp;amp;i",char2);&lt;BR /&gt;
		if _n_=&amp;amp;i then call symputx("char3f&amp;amp;i",char3);&lt;BR /&gt;
		/*if _n_=&amp;amp;i then call symputx("ilkdonem&amp;amp;i",ilkdonem);*/&lt;BR /&gt;
&lt;BR /&gt;
%end;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
 %do i=1 %to &amp;amp;ncan;&lt;BR /&gt;
	%do j=1 %to &amp;amp;ncan;&lt;BR /&gt;
&lt;BR /&gt;
		%if ("&amp;amp;&amp;amp;skodf&amp;amp;i" = "&amp;amp;&amp;amp;skodf&amp;amp;j") and ("&amp;amp;&amp;amp;char2f&amp;amp;i" = "&amp;amp;&amp;amp;char2f&amp;amp;j") and ("&amp;amp;&amp;amp;char3f&amp;amp;i" = "&amp;amp;&amp;amp;char3f&amp;amp;j") &lt;BR /&gt;
			%then  %do; &lt;BR /&gt;
					data libcan.aa&amp;amp;j; &lt;BR /&gt;
					set libcan.hoppala; &lt;BR /&gt;
						output1 = "LINE EXTENTION"; &lt;BR /&gt;
						if _n_=&amp;amp;j;&lt;BR /&gt;
					run; &lt;BR /&gt;
					%end;&lt;BR /&gt;
		%else %if ("&amp;amp;&amp;amp;skodf&amp;amp;i" = "&amp;amp;&amp;amp;skodf&amp;amp;j") and ("&amp;amp;&amp;amp;char2f&amp;amp;i" = "&amp;amp;&amp;amp;char2f&amp;amp;j") and ("&amp;amp;&amp;amp;char3f&amp;amp;i" NE "&amp;amp;&amp;amp;char3f&amp;amp;j") &lt;BR /&gt;
			%then %do;	&lt;BR /&gt;
					data libcan.aa&amp;amp;j; &lt;BR /&gt;
					set libcan.hoppala; &lt;BR /&gt;
					output2 = "BRAND EXTENSION";&lt;BR /&gt;
					if _n_=&amp;amp;j; &lt;BR /&gt;
					run; &lt;BR /&gt;
					%end;&lt;BR /&gt;
		%else %if ("&amp;amp;&amp;amp;skodf&amp;amp;i" NE "&amp;amp;&amp;amp;skodf&amp;amp;j") and ("&amp;amp;&amp;amp;char2f&amp;amp;i" = "&amp;amp;&amp;amp;char2f&amp;amp;j") and ("&amp;amp;&amp;amp;char3f&amp;amp;i" = "&amp;amp;&amp;amp;char3f&amp;amp;j") &lt;BR /&gt;
			%then %do;&lt;BR /&gt;
					data libcan.aa&amp;amp;j; &lt;BR /&gt;
					set libcan.hoppala; &lt;BR /&gt;
					output3 = "NEW CATEGORY TO BRAND";&lt;BR /&gt;
					if _n_=&amp;amp;j; &lt;BR /&gt;
					run; &lt;BR /&gt;
					%end;&lt;BR /&gt;
		%else %if ("&amp;amp;&amp;amp;skodf&amp;amp;i" NE "&amp;amp;&amp;amp;skodf&amp;amp;j") and ("&amp;amp;&amp;amp;char2f&amp;amp;i" = "&amp;amp;&amp;amp;char2f&amp;amp;j") and ("&amp;amp;&amp;amp;char3f&amp;amp;i" NE "&amp;amp;&amp;amp;char3f&amp;amp;j") &lt;BR /&gt;
			%then %do;&lt;BR /&gt;
					data libcan.aa&amp;amp;j; &lt;BR /&gt;
					set libcan.hoppala; &lt;BR /&gt;
					output4 = "NEW BRAND";&lt;BR /&gt;
					if _n_=&amp;amp;j; &lt;BR /&gt;
					run; &lt;BR /&gt;
					%end;&lt;BR /&gt;
		%else %if ("&amp;amp;&amp;amp;skodf&amp;amp;i" = "&amp;amp;&amp;amp;skodf&amp;amp;j") and ("&amp;amp;&amp;amp;char2f&amp;amp;i" NE "&amp;amp;&amp;amp;char2f&amp;amp;j") and ("&amp;amp;&amp;amp;char3f&amp;amp;i" NE "&amp;amp;&amp;amp;char3f&amp;amp;j") &lt;BR /&gt;
			%then %do;&lt;BR /&gt;
					data libcan.aa&amp;amp;j; &lt;BR /&gt;
					set libcan.hoppala; &lt;BR /&gt;
					output5 = "BLANK1";&lt;BR /&gt;
					if _n_=&amp;amp;j; &lt;BR /&gt;
					run; &lt;BR /&gt;
					%end;&lt;BR /&gt;
		 %else %if ("&amp;amp;&amp;amp;skodf&amp;amp;i" NE "&amp;amp;&amp;amp;skodf&amp;amp;j") and ("&amp;amp;&amp;amp;char2f&amp;amp;i" NE "&amp;amp;&amp;amp;char2f&amp;amp;j") and ("&amp;amp;&amp;amp;char3f&amp;amp;i" NE "&amp;amp;&amp;amp;char3f&amp;amp;j") &lt;BR /&gt;
			%then %do;&lt;BR /&gt;
					data libcan.aa&amp;amp;j; &lt;BR /&gt;
					set libcan.hoppala; &lt;BR /&gt;
					output6 = "BLANK2";&lt;BR /&gt;
					if _n_=&amp;amp;j; &lt;BR /&gt;
					run; &lt;BR /&gt;
					%end;&lt;BR /&gt;
		  %else %if ("&amp;amp;&amp;amp;skodf&amp;amp;i" NE "&amp;amp;&amp;amp;skodf&amp;amp;j") and ("&amp;amp;&amp;amp;char2f&amp;amp;i" NE "&amp;amp;&amp;amp;char2f&amp;amp;j") and ("&amp;amp;&amp;amp;char3f&amp;amp;i" = "&amp;amp;&amp;amp;char3f&amp;amp;j") &lt;BR /&gt;
			%then %do;&lt;BR /&gt;
					data libcan.aa&amp;amp;j; &lt;BR /&gt;
					set libcan.hoppala; &lt;BR /&gt;
					output7 = "BLANK3";&lt;BR /&gt;
					if _n_=&amp;amp;j; &lt;BR /&gt;
					run; &lt;BR /&gt;
					%end;&lt;BR /&gt;
		  %else %if ("&amp;amp;&amp;amp;skodf&amp;amp;i" = "&amp;amp;&amp;amp;skodf&amp;amp;j") and ("&amp;amp;&amp;amp;char2f&amp;amp;i" NE "&amp;amp;&amp;amp;char2f&amp;amp;j") and ("&amp;amp;&amp;amp;char3f&amp;amp;i" = "&amp;amp;&amp;amp;char3f&amp;amp;j") &lt;BR /&gt;
			%then %do;&lt;BR /&gt;
					data libcan.aa&amp;amp;j; &lt;BR /&gt;
					set libcan.hoppala; &lt;BR /&gt;
					output8 = "BLANK4";&lt;BR /&gt;
					if _n_=&amp;amp;j; &lt;BR /&gt;
					run; &lt;BR /&gt;
					%end;&lt;BR /&gt;
	%end;&lt;BR /&gt;
&lt;BR /&gt;
 %end;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data libcan.kategorize;&lt;BR /&gt;
	set&lt;BR /&gt;
		%do k=1 %to 10;&lt;BR /&gt;
	libcan.aa&amp;amp;k&lt;BR /&gt;
		%end;&lt;BR /&gt;
	;&lt;BR /&gt;
	run;&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
options mprint;&lt;BR /&gt;
options symbolgen;&lt;BR /&gt;
options macrogen;&lt;BR /&gt;
%test1;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I have problem with my macro function. First problem is:&lt;BR /&gt;
i get this: ERROR: Invalid symbolic variable name &amp;amp;&lt;BR /&gt;
and ERROR: Invalid symbolic variable name &amp;amp;&lt;BR /&gt;
errors.&lt;BR /&gt;
My aim is to categorize my dataset with some conditions above.&lt;BR /&gt;
But i can't because of these errors.&lt;BR /&gt;
Also i write my loop as i=1 and j=1 and suppose that my dataset look like:&lt;BR /&gt;
A B C&lt;BR /&gt;
D E F&lt;BR /&gt;
A C D&lt;BR /&gt;
&lt;BR /&gt;
SO; for i=1 and j=1  it should return LINE EXTENTION where it don't, it says it is BRAND EXTENSION. &lt;BR /&gt;
If someone understand where i am and try what to do, please help me.&lt;BR /&gt;
I am in trouble.</description>
      <pubDate>Mon, 20 Sep 2010 14:07:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73421#M15813</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-20T14:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Macro Loops , Macro Scope</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73422#M15814</link>
      <description>You need to remove the two leading ampersands from the three global statements in the beginning of the macro.  For example, when &amp;amp;i resolves to 1, the statement %global &amp;amp;&amp;amp;skodf&amp;amp;i; will resolve to %global &amp;amp;skodf1;, which produces an error because a macro variable name cannot include an ampersand.  This explains the error messages you referenced.  I suspect, however, that there may be a couple of additional problems with this code that you will still need to resolve.</description>
      <pubDate>Mon, 20 Sep 2010 15:44:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73422#M15814</guid>
      <dc:creator>polingjw</dc:creator>
      <dc:date>2010-09-20T15:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Macro Loops , Macro Scope</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73423#M15815</link>
      <description>@cakcan: I honestly don't know what you are trying to do. I get the vague sense that you are trying to compare an observation against another. See if below makes any sense to you. &lt;BR /&gt;
&lt;BR /&gt;
The output has all the combination of each observation (whose obs number indicated by i) compared against another (j), including itself. Given the pair of observations, then each of the three variables are compared: first var of the ith obs compared against the first var of the jth obs, and so on. &lt;BR /&gt;
&lt;BR /&gt;
The results of the comparisons are simply summarized by the code variable, where 1 means match and 0 means no-match. For instance, the code value of 100 indicates that the first variable value of the ith observation matched with the first variable value of the jth observation, but the second and the third variable values did not. Then using a format, the code is translated into type. Hope this helps a bit.&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
/* test data */&lt;BR /&gt;
data one;&lt;BR /&gt;
  input i (i1 i2 i3) (:$1.);&lt;BR /&gt;
cards;&lt;BR /&gt;
1 A B C&lt;BR /&gt;
2 A B D&lt;BR /&gt;
3 X B C&lt;BR /&gt;
4 X B Y&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* full join by itself */&lt;BR /&gt;
data two;&lt;BR /&gt;
  set one nobs=nobs;&lt;BR /&gt;
  do point = 1 to nobs;&lt;BR /&gt;
    set one(rename=(i=j i1=j1 i2=j2 i3=j3)) point=point;&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* generate type */&lt;BR /&gt;
proc format;&lt;BR /&gt;
  value $type &lt;BR /&gt;
    "111" = "line extention"&lt;BR /&gt;
    "110" = "brand extension"&lt;BR /&gt;
    "011" = "new category to brand"&lt;BR /&gt;
    "010" = "new brand"&lt;BR /&gt;
    other = "blank";&lt;BR /&gt;
run;&lt;BR /&gt;
data three;&lt;BR /&gt;
  set two;&lt;BR /&gt;
  code = cats(i1=j1, i2=j2, i3=j3);&lt;BR /&gt;
  type = put(code,$type21.);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* check */&lt;BR /&gt;
proc print data=three noobs;&lt;BR /&gt;
  var i j code type;&lt;BR /&gt;
run;&lt;BR /&gt;
/* on lst&lt;BR /&gt;
i    j    code    type&lt;BR /&gt;
&lt;BR /&gt;
1    1    111     line extention&lt;BR /&gt;
1    2    110     brand extension&lt;BR /&gt;
1    3    011     new category to brand&lt;BR /&gt;
1    4    010     new brand&lt;BR /&gt;
2    1    110     brand extension&lt;BR /&gt;
2    2    111     line extention&lt;BR /&gt;
2    3    010     new brand&lt;BR /&gt;
2    4    010     new brand&lt;BR /&gt;
3    1    011     new category to brand&lt;BR /&gt;
3    2    010     new brand&lt;BR /&gt;
3    3    111     line extention&lt;BR /&gt;
3    4    110     brand extension&lt;BR /&gt;
4    1    010     new brand&lt;BR /&gt;
4    2    010     new brand&lt;BR /&gt;
4    3    110     brand extension&lt;BR /&gt;
4    4    111     line extention&lt;BR /&gt;
*/&lt;BR /&gt;
[/pre]</description>
      <pubDate>Mon, 20 Sep 2010 20:25:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73423#M15815</guid>
      <dc:creator>chang_y_chung_hotmail_com</dc:creator>
      <dc:date>2010-09-20T20:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Macro Loops , Macro Scope</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73424#M15816</link>
      <description>Hi:&lt;BR /&gt;
  In addition to simplifying the logic and processing and deciding whether or not you need such a complicated program as the one you originally posted, As you see from the alternate solution that's been posted already, it is possible to solve some problems using non-macro approaches.&lt;BR /&gt;
&lt;BR /&gt;
When and if you do need to use multiple ampersands in a solution, you might also want to read some of the following material on using macro variables and indirect referencing of macro variables (what you have when you use multiple ampersands in your code).&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
 &lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a001071915.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a001071915.htm&lt;/A&gt;&lt;BR /&gt;
        &lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi30/165-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/165-30.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi27/p020-27.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi27/p020-27.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi22/ADVTUTOR/PAPER44.PDF" target="_blank"&gt;http://www2.sas.com/proceedings/sugi22/ADVTUTOR/PAPER44.PDF&lt;/A&gt;</description>
      <pubDate>Mon, 20 Sep 2010 23:42:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73424#M15816</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-09-20T23:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Macro Loops , Macro Scope</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73425#M15817</link>
      <description>Thank you polingjw.&lt;BR /&gt;
The error problem is solved by removing ampersands.</description>
      <pubDate>Tue, 21 Sep 2010 07:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73425#M15817</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-21T07:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Macro Loops , Macro Scope</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73426#M15818</link>
      <description>But the other problem still occurs.&lt;BR /&gt;
I'll try to explain my point of view. I have a large dataset and my aim is to categorize all rows to some conditions. For example my dataset looks like this:&lt;BR /&gt;
SKOD ILKDONEM CHAR2      CHAR3&lt;BR /&gt;
01        9509           PG              KROMASH&lt;BR /&gt;
01        9805           OTHER        SUPMAX&lt;BR /&gt;
01        9807           PG               PERMATIK&lt;BR /&gt;
02        9509           ASTOR        ASTOR&lt;BR /&gt;
03        9709           PERSON     PERSONN&lt;BR /&gt;
03        9906           OTHER        SUPMAX&lt;BR /&gt;
..           ..                 ..                      ..&lt;BR /&gt;
..           ..                 ..                      ..&lt;BR /&gt;
&lt;BR /&gt;
So my categorization criteria depends on 4 conditions:&lt;BR /&gt;
1. LINE EXTENSION&lt;BR /&gt;
("&amp;amp;&amp;amp;skodf&amp;amp;i" = "&amp;amp;&amp;amp;skodf&amp;amp;j") and ("&amp;amp;&amp;amp;char2f&amp;amp;i" = "&amp;amp;&amp;amp;char2f&amp;amp;j") and ("&amp;amp;&amp;amp;char3f&amp;amp;i" = "&amp;amp;&amp;amp;char3f&amp;amp;j")&lt;BR /&gt;
2. BRAD EXTENSION&lt;BR /&gt;
("&amp;amp;&amp;amp;skodf&amp;amp;i" = "&amp;amp;&amp;amp;skodf&amp;amp;j") and ("&amp;amp;&amp;amp;char2f&amp;amp;i" = "&amp;amp;&amp;amp;char2f&amp;amp;j") and ("&amp;amp;&amp;amp;char3f&amp;amp;i" NE "&amp;amp;&amp;amp;char3f&amp;amp;j")&lt;BR /&gt;
3. NEW CATEGORY TO BRAND&lt;BR /&gt;
("&amp;amp;&amp;amp;skodf&amp;amp;i" NE "&amp;amp;&amp;amp;skodf&amp;amp;j") and ("&amp;amp;&amp;amp;char2f&amp;amp;i" = "&amp;amp;&amp;amp;char2f&amp;amp;j") and ("&amp;amp;&amp;amp;char3f&amp;amp;i" = "&amp;amp;&amp;amp;char3f&amp;amp;j")&lt;BR /&gt;
4. NEW BRAND&lt;BR /&gt;
("&amp;amp;&amp;amp;skodf&amp;amp;i" NE "&amp;amp;&amp;amp;skodf&amp;amp;j") and ("&amp;amp;&amp;amp;char2f&amp;amp;i" = "&amp;amp;&amp;amp;char2f&amp;amp;j") and ("&amp;amp;&amp;amp;char3f&amp;amp;i" NE "&amp;amp;&amp;amp;char3f&amp;amp;j")&lt;BR /&gt;
&lt;BR /&gt;
So, every row in the dataset should be categorized by these categories.&lt;BR /&gt;
So for my loop starts as:&lt;BR /&gt;
i=1 j=1&lt;BR /&gt;
my first row of my dataset is equal to each other so it should output as:&lt;BR /&gt;
LINE EXTENSION and also create a new dataset for each every row and finally, at the end it should merge all the output datasets togather so that i got to my point.&lt;BR /&gt;
But my macro doesnt work like i think. It gives BRAND EXTENSION to my first row, and so on goes wrong like this. I don't understand why.&lt;BR /&gt;
I don't want to change the algorithm (using macro), if someone have an idea where i'm wrong, please correct me. It would be great for me.</description>
      <pubDate>Tue, 21 Sep 2010 07:50:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73426#M15818</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-21T07:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Macro Loops , Macro Scope</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73427#M15819</link>
      <description>I'd say: lean back, take a deep breath and seriously look at Chang's suggestion. The code he provided seems perfectly suited to the task as you outlined it in the first post of this thread.&lt;BR /&gt;
&lt;BR /&gt;
If the code (especially macro code) gets too complicated that's very often a "heads-up" like indicator to rethink the strategy.</description>
      <pubDate>Tue, 21 Sep 2010 08:27:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73427#M15819</guid>
      <dc:creator>Robert_Bardos</dc:creator>
      <dc:date>2010-09-21T08:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Macro Loops , Macro Scope</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73428#M15820</link>
      <description>I've fixed the problem, it's just because merging the output datasets and overwriting problem. Just created a unique macro variable for incrementing the output sas tables differing from the loop variables (i,j) and it just worked.&lt;BR /&gt;
&lt;BR /&gt;
Thank you guys,&lt;BR /&gt;
Can Akcan</description>
      <pubDate>Tue, 21 Sep 2010 09:55:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-in-Macro-Loops-Macro-Scope/m-p/73428#M15820</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-21T09:55:59Z</dc:date>
    </item>
  </channel>
</rss>

