<?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 macro with &amp;quot;numerator&amp;quot; doesn't work in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52350#M11062</link>
    <description>Dear SAS support,&lt;BR /&gt;
&lt;BR /&gt;
I have a question concerning a macro I want to apply:&lt;BR /&gt;
I have data that contains information about the brands someone has bought. The variable I'm refering to is called brand in my dataset, and it can have values from 1 to 33, because their are 33 different brands.&lt;BR /&gt;
Now I want to have the price information of every brand in each line, so I'm transposing the file. Since I don't want write down 33 different conditions, I wanted to use a macro. I introduced a local variable named numerator, that should count from 1 to 33 (which is _number). But it doesn't seem to work. I never get the right prices in the new price_br&amp;amp;numerator variables, but just "."s. Can somebody help me and tell me what I'm doing wrong here?&lt;BR /&gt;
&lt;BR /&gt;
%LET _number = 33;&lt;BR /&gt;
&lt;BR /&gt;
PROC TRANSPOSE DATA = data_01 OUT = data_02;&lt;BR /&gt;
	BY id week;&lt;BR /&gt;
	ID brand;&lt;BR /&gt;
	VAR price_brand;&lt;BR /&gt;
	RUN;&lt;BR /&gt;
&lt;BR /&gt;
%MACRO _macro12;&lt;BR /&gt;
	%LOCAL numerator;&lt;BR /&gt;
			DATA data_03;&lt;BR /&gt;
				SET data_02;&lt;BR /&gt;
				DROP _name_ _label_;&lt;BR /&gt;
				%DO numerator = 1 %TO &amp;amp;_nobr.;&lt;BR /&gt;
					price_br&amp;amp;numerator. = _&amp;amp;numerator.;&lt;BR /&gt;
					DROP _&amp;amp;numerator.;&lt;BR /&gt;
					IF price_br&amp;amp;numerator. EQ . THEN regpr&amp;amp;numerator. = 0;&lt;BR /&gt;
				%END;&lt;BR /&gt;
				RUN; &lt;BR /&gt;
		%MEND;&lt;BR /&gt;
%_macro12;&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
yel10orblu</description>
    <pubDate>Sun, 18 Jul 2010 14:18:58 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-07-18T14:18:58Z</dc:date>
    <item>
      <title>macro with "numerator" doesn't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52350#M11062</link>
      <description>Dear SAS support,&lt;BR /&gt;
&lt;BR /&gt;
I have a question concerning a macro I want to apply:&lt;BR /&gt;
I have data that contains information about the brands someone has bought. The variable I'm refering to is called brand in my dataset, and it can have values from 1 to 33, because their are 33 different brands.&lt;BR /&gt;
Now I want to have the price information of every brand in each line, so I'm transposing the file. Since I don't want write down 33 different conditions, I wanted to use a macro. I introduced a local variable named numerator, that should count from 1 to 33 (which is _number). But it doesn't seem to work. I never get the right prices in the new price_br&amp;amp;numerator variables, but just "."s. Can somebody help me and tell me what I'm doing wrong here?&lt;BR /&gt;
&lt;BR /&gt;
%LET _number = 33;&lt;BR /&gt;
&lt;BR /&gt;
PROC TRANSPOSE DATA = data_01 OUT = data_02;&lt;BR /&gt;
	BY id week;&lt;BR /&gt;
	ID brand;&lt;BR /&gt;
	VAR price_brand;&lt;BR /&gt;
	RUN;&lt;BR /&gt;
&lt;BR /&gt;
%MACRO _macro12;&lt;BR /&gt;
	%LOCAL numerator;&lt;BR /&gt;
			DATA data_03;&lt;BR /&gt;
				SET data_02;&lt;BR /&gt;
				DROP _name_ _label_;&lt;BR /&gt;
				%DO numerator = 1 %TO &amp;amp;_nobr.;&lt;BR /&gt;
					price_br&amp;amp;numerator. = _&amp;amp;numerator.;&lt;BR /&gt;
					DROP _&amp;amp;numerator.;&lt;BR /&gt;
					IF price_br&amp;amp;numerator. EQ . THEN regpr&amp;amp;numerator. = 0;&lt;BR /&gt;
				%END;&lt;BR /&gt;
				RUN; &lt;BR /&gt;
		%MEND;&lt;BR /&gt;
%_macro12;&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
yel10orblu</description>
      <pubDate>Sun, 18 Jul 2010 14:18:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52350#M11062</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-18T14:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: macro with "numerator" doesn't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52351#M11063</link>
      <description>Hi:&lt;BR /&gt;
  Two questions:&lt;BR /&gt;
1) where does the value for &amp;amp;_nobr macro variable come from??? (shown in the line: %DO numerator = 1 %TO &amp;amp;_nobr.; )&lt;BR /&gt;
        &lt;BR /&gt;
2) Can you show a small sample of what your input data looks like and what your transposed data looks like? Posting a small PROC PRINT of the DATA_01 before the transpose and the DATA_02 after the transpose would work nicely. &lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Sun, 18 Jul 2010 14:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52351#M11063</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-07-18T14:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: macro with "numerator" doesn't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52352#M11064</link>
      <description>Dear cynthia,&lt;BR /&gt;
&lt;BR /&gt;
1) I'm sorry, the &amp;amp;_nobr of course has to be &amp;amp;_number  (%DO numerator = 1 %TO &amp;amp;_number.;)  ... I changed the variable names so that it yould be easier for someone who doesn't know the data but forgot that one.&lt;BR /&gt;
&lt;BR /&gt;
2)&lt;BR /&gt;
&lt;BR /&gt;
input file data_01&lt;BR /&gt;
&lt;BR /&gt;
Obs ID brand WEEK price_brand &lt;BR /&gt;
1 1 2 14274 .  &lt;BR /&gt;
2 1 3 14274 30.7454 &lt;BR /&gt;
3 1 5 14274 .  &lt;BR /&gt;
4 1 6 14274 .  &lt;BR /&gt;
5 1 7 14274 .  &lt;BR /&gt;
6 1 8 14274 .  &lt;BR /&gt;
7 1 2 14277 .  &lt;BR /&gt;
8 1 3 14277 30.7454 &lt;BR /&gt;
9 1 5 14277 .  &lt;BR /&gt;
10 1 6 14277 .  &lt;BR /&gt;
11 1 7 14277 .  &lt;BR /&gt;
12 1 8 14277 . &lt;BR /&gt;
13 1 2 14280 .  &lt;BR /&gt;
14 1 3 14280 30.7454 &lt;BR /&gt;
15 1 5 14280 .  &lt;BR /&gt;
16 1 6 14280 .  &lt;BR /&gt;
17 1 7 14280 .  &lt;BR /&gt;
18 1 8 14280 .  &lt;BR /&gt;
19 1 2 14290 .  &lt;BR /&gt;
20 1 3 14290 30.7454 &lt;BR /&gt;
21 1 5 14290 .  &lt;BR /&gt;
22 1 6 14290 .  &lt;BR /&gt;
23 1 7 14290 .  &lt;BR /&gt;
24 1 8 14290 .  &lt;BR /&gt;
25 1 2 14299 .  &lt;BR /&gt;
26 1 3 14299 30.7454 &lt;BR /&gt;
27 1 5 14299 .  &lt;BR /&gt;
28 1 6 14299 15.4605 &lt;BR /&gt;
29 1 7 14299 .  &lt;BR /&gt;
30 1 8 14299 .  &lt;BR /&gt;
31 1 2 14314 .  &lt;BR /&gt;
32 1 3 14314 30.7454 &lt;BR /&gt;
33 1 5 14314 .  &lt;BR /&gt;
34 1 6 14314 15.4605 &lt;BR /&gt;
35 1 7 14314 .  &lt;BR /&gt;
36 1 8 14314 .  &lt;BR /&gt;
37 1 2 14334 .  &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
transposed file data_02&lt;BR /&gt;
&lt;BR /&gt;
Obs ID WEEK _NAME_ _LABEL_ 2 3 5 6 7 8 1 4 &lt;BR /&gt;
1 1 14274 price_brand price .  30.7454 .  .  .  .  .  .  &lt;BR /&gt;
2 1 14277 price_brand price .  30.7454 .  .  .  .  .  .  &lt;BR /&gt;
3 1 14280 price_brand price .  30.7454 .  .  .  .  .  .  &lt;BR /&gt;
4 1 14290 price_brand price .  30.7454 .  .  .  .  .  .  &lt;BR /&gt;
5 1 14299 price_brand price .  30.7454 .  15.4605 .  .  .  .  &lt;BR /&gt;
6 1 14314 price_brand price .  30.7454 .  15.4605 .  .  .  .  &lt;BR /&gt;
7 1 14334 price_brand price .  30.7454 .  15.4605 .  .  .  .  &lt;BR /&gt;
8 1 14343 price_brand price .  30.7454 .  15.4605 .  .  .  .  &lt;BR /&gt;
9 1 14344 price_brand price .  30.7454 .  15.4605 .  .  .  .  &lt;BR /&gt;
10 1 14349 price_brand price .  30.7454 .  15.4605 .  .  .  .  &lt;BR /&gt;
11 1 14351 price_brand price .  30.7454 .  15.4605 .  .  .  . &lt;BR /&gt;
&lt;BR /&gt;
Does that help you? Let me know if you need anything else...</description>
      <pubDate>Sun, 18 Jul 2010 15:40:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52352#M11064</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-18T15:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: macro with "numerator" doesn't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52353#M11065</link>
      <description>Hi:&lt;BR /&gt;
  I'm curious about several things...&lt;BR /&gt;
1) the headers that you show for the transposed data:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Obs ID WEEK _NAME_ _LABEL_ 2 3 5 6 7 8 1 4 &lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
In the data you show, BRAND only has values of 2, 3, 5, 6, 7 and 8. Yet, in your headers, you also appear to have values for BRAND of 1 and 4??? is this correct??? Is this what you mean when you say you could have 33 -- you could have 33 brands????&lt;BR /&gt;
&lt;BR /&gt;
2) in your original post you say:&lt;BR /&gt;
"Now I want to have the price information of every brand in each line, so I'm transposing the file. Since I don't want write down 33 different conditions, I wanted to use a macro." I don't understand what you mean by these terms: "in each line"?? In each observation?? "write down 33 different conditions"?? Where would you write 33 different conditions???&lt;BR /&gt;
 &lt;BR /&gt;
3) Are you sure that the TRANSPOSE you posted generates the DATA_02 results that you posted??? When I use the snippet of data that you provided and use your posted TRANSPOSE code, I get different results. See below. Note that my transposed variables start with _ (underscore) and I only have _2 through _8. It looks like the price for brand 3 is always 30.7454 and the price for brand 6 is always 15.4605 -- is this correct?? Why don't the other brands have prices???&lt;BR /&gt;
&lt;BR /&gt;
4) Now that you've shown DATA_01 and DATA_02 (assuming that one of our posts of DATA_02 is correct), can you show a "dummy" version of DATA_03 and what your final desired TABLE should look like???? &lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
         &lt;BR /&gt;
RESULTS:&lt;BR /&gt;
[pre]&lt;BR /&gt;
     Obs    ID     week      _NAME_       _2       _3      _5       _6      _7    _8&lt;BR /&gt;
&lt;BR /&gt;
      1      1    14274    price_brand     .    30.7454     .      .         .     .&lt;BR /&gt;
      2      1    14277    price_brand     .    30.7454     .      .         .     .&lt;BR /&gt;
      3      1    14280    price_brand     .    30.7454     .      .         .     .&lt;BR /&gt;
      4      1    14290    price_brand     .    30.7454     .      .         .     .&lt;BR /&gt;
      5      1    14299    price_brand     .    30.7454     .    15.4605     .     .&lt;BR /&gt;
      6      1    14314    price_brand     .    30.7454     .    15.4605     .     .&lt;BR /&gt;
      7      1    14334    price_brand     .      .         .      .         .     .&lt;BR /&gt;
[/pre]</description>
      <pubDate>Sun, 18 Jul 2010 17:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52353#M11065</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-07-18T17:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: macro with "numerator" doesn't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52354#M11066</link>
      <description>Hi cynthia,&lt;BR /&gt;
&lt;BR /&gt;
thank you so much for your quick reply.&lt;BR /&gt;
&lt;BR /&gt;
1) Yes, I do indeed have values for brand 1 and 4, and also for all the brands up to 33 brands. &lt;BR /&gt;
&lt;BR /&gt;
2) It's the macro that doesn't work for me. The line price_br&amp;amp;numerator. = _&amp;amp;numerator.; doesn't seem to work. So if I would have to do it "the complicated way", I would have to write down price_br1 = 1; price_br2=2 and so on (33 times). And since I have more variables that need to be transposed (for example, data on advertising), that would be some really hard work. And please excuse my bad English: Yes, with each line I mean each observation.&lt;BR /&gt;
&lt;BR /&gt;
3) The results you're getting here are perfectly fine. The prices are the same for all the weeks because there was no price cut (that's different for other observations in the dataset). The other brands don't have prices here because ID refers to a certain store that carries only certain brands. Most other stores carry more brands.&lt;BR /&gt;
&lt;BR /&gt;
4)&lt;BR /&gt;
&lt;BR /&gt;
Obs__ID__week____price_br1____price_br2_____price_br3_____ ... ___price_br33&lt;BR /&gt;
1____1___14274___0___________0____________30.7454_______ ...___24.3342__&lt;BR /&gt;
2____1___14277___0___________0____________30.7454_______ ...___24.3342__&lt;BR /&gt;
3____1___14280___0___________0____________30.7454_______ ...___24.3342__&lt;BR /&gt;
4____1___14290___0___________0____________30.7454_______ ...___24.3342__&lt;BR /&gt;
5____1___14277___0___________0____________30.7454_______ ...___24.3342__&lt;BR /&gt;
6____1___14314___0___________0____________30.7454_______ ...___24.3342__&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Also, sorry again, there was another mistake in the code. Instead of regpr it should be price_br of course...&lt;BR /&gt;
&lt;BR /&gt;
Here's the updated code:&lt;BR /&gt;
&lt;BR /&gt;
%LET _number = 33;&lt;BR /&gt;
&lt;BR /&gt;
PROC TRANSPOSE DATA = data_01 OUT = data_02;&lt;BR /&gt;
BY id week;&lt;BR /&gt;
ID brand;&lt;BR /&gt;
VAR price_brand;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
%MACRO _macro12;&lt;BR /&gt;
%LOCAL numerator;&lt;BR /&gt;
DATA data_03;&lt;BR /&gt;
SET data_02;&lt;BR /&gt;
DROP _name_ _label_;&lt;BR /&gt;
%DO numerator = 1 %TO &amp;amp;_numerator.;&lt;BR /&gt;
price_br&amp;amp;numerator. = _&amp;amp;numerator.;&lt;BR /&gt;
DROP _&amp;amp;numerator.;&lt;BR /&gt;
IF price_br&amp;amp;numerator. EQ . THEN price_br&amp;amp;numerator. = 0;&lt;BR /&gt;
%END;&lt;BR /&gt;
RUN;&lt;BR /&gt;
%MEND;&lt;BR /&gt;
%_macro12;</description>
      <pubDate>Sun, 18 Jul 2010 17:25:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52354#M11066</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-18T17:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: macro with "numerator" doesn't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52355#M11067</link>
      <description>What generates the macro variable called &amp;amp;_numerator?  Is that your _number?&lt;BR /&gt;
&lt;BR /&gt;
Does this macro even execute with success, given this comment?&lt;BR /&gt;
&lt;BR /&gt;
Also, consider this forum is *NOT* SAS Support, though the fine technical staff at SAS Institute frequently contribute and are quite diligent with input/feedback as subscribers, at all hours of the day/night I might add.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Sun, 18 Jul 2010 17:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52355#M11067</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-07-18T17:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: macro with "numerator" doesn't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52356#M11068</link>
      <description>Argh, again a mistake in the code...&lt;BR /&gt;
&lt;BR /&gt;
%LET _number = 33;&lt;BR /&gt;
&lt;BR /&gt;
PROC TRANSPOSE DATA = data_01 OUT = data_02;&lt;BR /&gt;
BY id week;&lt;BR /&gt;
ID brand;&lt;BR /&gt;
VAR price_brand;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
%MACRO _macro12;&lt;BR /&gt;
%LOCAL numerator;&lt;BR /&gt;
DATA data_03;&lt;BR /&gt;
SET data_02;&lt;BR /&gt;
DROP _name_ _label_;&lt;BR /&gt;
%DO numerator = 1 %TO &amp;amp;_number.;&lt;BR /&gt;
price_br&amp;amp;numerator. = _&amp;amp;numerator.;&lt;BR /&gt;
DROP _&amp;amp;numerator.;&lt;BR /&gt;
IF price_br&amp;amp;numerator. EQ . THEN price_br&amp;amp;numerator. = 0;&lt;BR /&gt;
%END;&lt;BR /&gt;
RUN;&lt;BR /&gt;
%MEND;&lt;BR /&gt;
%_macro12; &lt;BR /&gt;
&lt;BR /&gt;
The _numerator is defined by _number, that's right.&lt;BR /&gt;
&lt;BR /&gt;
Yes, the macro does execute.&lt;BR /&gt;
However, I get a message saying: NOTE: Variable _1 is uninitialized. NOTE: Variable _2 is uninitialized. and so on..&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I'm sorry if my questions don't belong in that forum, so do you reckon I write an e-mail to the SAS support team?</description>
      <pubDate>Sun, 18 Jul 2010 17:59:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52356#M11068</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-18T17:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: macro with "numerator" doesn't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52357#M11069</link>
      <description>This type of post is quite typical....however:&lt;BR /&gt;
&lt;BR /&gt;
You would be best served by posting a reply with your SAS log pasted directly to the forum, nothing less -- consider the time wasted with inconsistencies and that now you are sharing more about the "symptom" you are getting.&lt;BR /&gt;
&lt;BR /&gt;
More important, you should always consider getting a code-sample to work correctly and then if needed implement other SAS programming techniques that help improve efficiency, here that would be the use of the macro language.&lt;BR /&gt;
&lt;BR /&gt;
If you do a PROC CONTENTS on the output file from TRANSPOSE or add a PUTLOG _ALL_;  to your DATA step, I'm convinced you will see the problem through self-diagnosis along with desk-checking your SAS program with this statement added (MGEN is short for MACROGEN and similar for SGEN and SYMBOLGEN):&lt;BR /&gt;
&lt;BR /&gt;
OPTIONS SOURCE SOURCE2 MGEN SGEN MLOGIC MPRINT;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Sun, 18 Jul 2010 18:22:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52357#M11069</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-07-18T18:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: macro with "numerator" doesn't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52358#M11070</link>
      <description>Hi:&lt;BR /&gt;
  Scott asks a good question. You show this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
%MACRO _macro12;&lt;BR /&gt;
%LOCAL numerator;&lt;BR /&gt;
DATA data_03;&lt;BR /&gt;
SET data_02;&lt;BR /&gt;
DROP _name_ _label_;&lt;BR /&gt;
%DO numerator = 1 %TO &amp;amp;_numerator.;&lt;BR /&gt;
price_br&amp;amp;numerator. = _&amp;amp;numerator.;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Your %LOCAL refers to NUMERATOR as a local macro variable (without any underscores in the name.) This means that the correct reference is &amp;amp;NUMERATOR. And yet, in your code, you show 2 completely different macro variable references: &amp;amp;_NUMERATOR and _&amp;amp;NUMERATOR -- neither of which will be the same as &amp;amp;NUMERATOR. So right off the bat, you have a problem...you have 3 possible macro variables, one of them local and in your code you have this:&lt;BR /&gt;
&lt;B&gt;%DO numerator = 1 %TO &amp;amp;_numerator.; &lt;/B&gt; which seems to me should be:&lt;BR /&gt;
&lt;B&gt;%DO numerator = 1 %TO &amp;amp;_number.; &lt;/B&gt; or&lt;BR /&gt;
&lt;B&gt;%DO numerator = 1 %TO 33;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
And THEN your %LET statement refers to _NUMBER -- a 4th possible macro variable, whose limit is set to 33. And it seems to me that you really want the DO loop to go from 1 to 33, (which is &amp;amp;_NUMBER) and not from 1 to &amp;amp;_NUMERATOR or _&amp;amp;NUMERATOR???? Is that correct???&lt;BR /&gt;
&lt;BR /&gt;
I understand that you don't like the _2, _3, _4, etc naming convention that you get from PROC TRANSPOSE -- however, that can EASILY be solved by using the PROC TRANSPOSE PREFIX= option which will put the same prefix in front of each TRANSPOSED variable. So, instead of getting _2, _3, etc, you could have PREFIX=PB or PREFIX=PRICE_BR and you would get PB1, PB2, PB3, PB4 or PRICE_BR1, PRICE_BR2, PRICE_BR3, PRICE_BR4 as the names of your variables after the transpose.&lt;BR /&gt;
 &lt;BR /&gt;
As for the issue of how to turn the missing values (.) for transposed prices into 0 that is a fairly simple task for a simple DATA step ARRAY with a simple DO loop - no macro coding required.&lt;BR /&gt;
 &lt;BR /&gt;
I'm not convinced that you really need a SAS Macro solution here. I don't see anything that you could not also accomplish and accomplish easier with a simple DATA step DO loop.&lt;BR /&gt;
 &lt;BR /&gt;
This paper gives a good introduction to simple ARRAY processing with SAS (without using SAS macros)&lt;BR /&gt;
&lt;A href="http://support.sas.com/rnd/papers/sgf07/arrays1780.pdf" target="_blank"&gt;http://support.sas.com/rnd/papers/sgf07/arrays1780.pdf&lt;/A&gt; &lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
ps...consider either of these PROC TRANSPOSE steps as an alternative to what you are currently using the code below...note that they create DATA_02A and DATA_02B, so you can compare the 2 output datasets created:&lt;BR /&gt;
[pre]&lt;BR /&gt;
PROC TRANSPOSE DATA = data_01 OUT = data_02A(drop=_NAME_)&lt;BR /&gt;
     prefix=pb;&lt;BR /&gt;
  BY id week;&lt;BR /&gt;
  ID brand;&lt;BR /&gt;
  VAR price_brand;&lt;BR /&gt;
RUN;&lt;BR /&gt;
                                           &lt;BR /&gt;
PROC TRANSPOSE DATA = data_01 OUT = data_02B(drop=_NAME_)&lt;BR /&gt;
     prefix=price_br;&lt;BR /&gt;
  BY id week;&lt;BR /&gt;
  ID brand;&lt;BR /&gt;
  VAR price_brand;&lt;BR /&gt;
RUN;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Sun, 18 Jul 2010 18:33:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52358#M11070</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-07-18T18:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: macro with "numerator" doesn't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52359#M11071</link>
      <description>Also, regarding the use of an ARRAY, I quickly scanned the conference paper cited and did not noticee the use of a generic variable prefix list in the ARRAY statement to avoid the need to know how many elements are in the array - here's an example, where I frequently use the approach to reset missing values to zero or just the opposite (zero to missing, with OPTIONS MISSING=' ';) for easier report readability:&lt;BR /&gt;
&lt;BR /&gt;
DATA _NULL_;&lt;BR /&gt;
RETAIN NUM1-NUM5 . NUM6-NUM9 0;&lt;BR /&gt;
ARRAY ANUM (*) NUM: ;&lt;BR /&gt;
DO I=1 TO DIM(ANUM);&lt;BR /&gt;
  IF ANUM(I) = . THEN ANUM(I) = 0;&lt;BR /&gt;
END;&lt;BR /&gt;
PUTLOG _ALL_;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Sun, 18 Jul 2010 19:37:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52359#M11071</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-07-18T19:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: macro with "numerator" doesn't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52360#M11072</link>
      <description>Scott:&lt;BR /&gt;
  I thought of that.&lt;BR /&gt;
&lt;BR /&gt;
  However, he says he KNOWS that the count of potential brands is fixed at 33. He sets &amp;amp;_NUMBER to 33. So a DO loop (as opposed to a %DO loop) that goes from 1 to 33 should be OK. &lt;BR /&gt;
&lt;BR /&gt;
  And, besides, if I gave away all the -other- paper references in the first post, I'd have nothing to follow up with!&lt;BR /&gt;
&lt;BR /&gt;
cynthia&lt;BR /&gt;
 &lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi30/242-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/242-30.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.stat.berkeley.edu/~spector/array.pdf" target="_blank"&gt;http://www.stat.berkeley.edu/~spector/array.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/resources/papers/proceedings09/032-2009.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings09/032-2009.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.uncg.edu/bae/people/ribar/teaching/ECO725/notes/SAS_arrays.pdf" target="_blank"&gt;http://www.uncg.edu/bae/people/ribar/teaching/ECO725/notes/SAS_arrays.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.afhood.com/blog/?p=234" target="_blank"&gt;http://www.afhood.com/blog/?p=234&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/24/570.html" target="_blank"&gt;http://support.sas.com/kb/24/570.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi26/p073-26.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi26/p073-26.pdf&lt;/A&gt; (about the use of the colon modifier)&lt;BR /&gt;
cynthia</description>
      <pubDate>Sun, 18 Jul 2010 20:13:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52360#M11072</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-07-18T20:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: macro with "numerator" doesn't work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52361#M11073</link>
      <description>Thank you both so much for your valuable comments, you really helped me out here!!</description>
      <pubDate>Mon, 19 Jul 2010 07:50:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-with-quot-numerator-quot-doesn-t-work/m-p/52361#M11073</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-07-19T07:50:26Z</dc:date>
    </item>
  </channel>
</rss>

