<?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: Output statement in macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337879#M76808</link>
    <description>&lt;P&gt;Hi:&lt;BR /&gt; Your question "will macro 'work' with simple do loop" implies to me that you think the macro program is doing all the work. It it not. &lt;BR /&gt;&lt;BR /&gt; The macro program is simply generating the code that will be sent to the compiler. &lt;BR /&gt;&lt;BR /&gt; If you run the program that was provided to you and turn on the MPRINT option, you will be able to see the code that goes forward to the compiler.&lt;BR /&gt;&lt;BR /&gt; I made a few slight changes to the program so that the stop value for the loop is set based on the COUNTW value -- that way, you do not have to hardcode the count value to create the last obs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here are some papers that may help: &lt;A href="https://support.sas.com/resources/papers/proceedings13/120-2013.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings13/120-2013.pdf&lt;/A&gt; and &lt;A href="http://www2.sas.com/proceedings/sugi28/056-28.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi28/056-28.pdf&lt;/A&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;BR /&gt; &lt;BR /&gt;cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7553i47D53EDEBF873E33/image-size/original?v=1.0&amp;amp;px=-1" alt="use_mprint.png" title="use_mprint.png" border="0" /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Mar 2017 16:14:55 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2017-03-03T16:14:55Z</dc:date>
    <item>
      <title>Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337517#M76647</link>
      <description>&lt;P&gt;Can we write output statement in a macro?&lt;/P&gt;&lt;P&gt;In below example i want the same output in macro as in normal sas code.&lt;/P&gt;&lt;P&gt;Please correct my macro code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;SAS code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Word;&lt;BR /&gt;Name_list="Ramya Ranjan Sahu";&lt;BR /&gt;do i=1 to countw(Name_list)+1;&lt;BR /&gt;Word=scan(Name_list,i);&lt;BR /&gt;if i=4 then Word="No More Words";&lt;BR /&gt;Output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output Table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name_List &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i &amp;nbsp; &amp;nbsp;Word&lt;/P&gt;&lt;P&gt;Ramya Ranjan Sahu &amp;nbsp;1 &amp;nbsp;Ramya&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ramya Ranjan Sahu &amp;nbsp;2 &amp;nbsp;Ranjan&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ramya Ranjan Sahu &amp;nbsp;3 &amp;nbsp;Sahu&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ramya Ranjan Sahu &amp;nbsp;4&amp;nbsp;&amp;nbsp;No More Words&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Using Macro Code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let i=1;&lt;BR /&gt;%let name_list = Ramya Ranjan Sahu;&lt;/P&gt;&lt;P&gt;%macro Name;&lt;BR /&gt;data word;&lt;BR /&gt;%do i = 1 %to %eval(%sysfunc(countw(&amp;amp;name_list))+1);&lt;BR /&gt;%let word=%scan(&amp;amp;name_list,&amp;amp;i);&lt;BR /&gt;%if &amp;amp;i=4 %then %do; Word="No More Words"; %end;&lt;BR /&gt;&lt;STRONG&gt;output;&lt;/STRONG&gt;&lt;BR /&gt;%end;&lt;BR /&gt;format word $15.;&lt;BR /&gt;%run;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output Table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Word&lt;/P&gt;&lt;P&gt;Blank&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Blank&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Blank&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;No More Words&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 19:28:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337517#M76647</guid>
      <dc:creator>ramya_sahu</dc:creator>
      <dc:date>2017-03-02T19:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337533#M76654</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt; I don't understand what you mean when you say "i want the same output in macro as in normal sas code" -- the SAS Macro processor is only generating SAS code. By the time your code gets to the compiler, there are NO &amp;amp; or % references left in it. Or, as I like to joke with my students "what happens in macro, stays in macro". (OK, maybe it's not that funny a joke.)&lt;BR /&gt;&lt;BR /&gt; But the bottom line is that the macro processor is NOT causing anything to execute. I am not sure what you thought you were sending to the compiler, but If you turn on the MPRINT option, you can see exactly what did get sent.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7534i08FFA066F2E9B365/image-size/original?v=1.0&amp;amp;px=-1" alt="final_program.png" title="final_program.png" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are expecting a different result, then you'll need different logic. but since the logic of what you want to do isn't clear, you might need to explain. Some questions that are in my mind are:&lt;/P&gt;
&lt;P&gt;-- are you only ever using this program with a value for &amp;amp;name_list that will ALWAYS be 3 names? What about names like&lt;/P&gt;
&lt;P&gt;Cher? or&lt;/P&gt;
&lt;P&gt;John Jacob Jingleheimer Smith? Or&lt;/P&gt;
&lt;P&gt;Jacqueline Bouvier Kennedy Onassis? or&lt;/P&gt;
&lt;P&gt;The Artist Formerly Known as Prince? or&lt;/P&gt;
&lt;P&gt;Johannes Chrysostomus Wolfgangus Theophilus Mozart?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some of those names are fewer than 3 names and some of those names are more than 3 levels.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-- why test for &amp;amp;1=4 instead of using a %DO %WHILE or %DO %UNTIL&lt;/P&gt;
&lt;P&gt;--why do this in a macro program at all?&lt;/P&gt;
&lt;P&gt;-- the %LET Statement creates a macro variable in the Global Symbol Table, NOT in your output table so you might need to consider a different statement there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When working with Macro programs, it is useful to start with a working SAS program that does what you want and then work backward to a macro program that will generate the working SAS code.&lt;BR /&gt;&lt;BR /&gt;cynthia&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 20:08:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337533#M76654</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-03-02T20:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337534#M76655</link>
      <description>&lt;P&gt;You can, but you have to visualize the resulting program to make sure it's something you want to do.&amp;nbsp; In this case, the generated SAS code looks like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data word;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;Word="No More Words";&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's probably not the result you are hoping for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let word= assigns a value to a macro variable &amp;amp;WORD, which has absolutely nothing to do with a SAS DATA step.&amp;nbsp; While you can fix the problem with a change to one statement, it will require understanding the relationship between macro language and SAS language for this to be useful to you.&amp;nbsp; Here is just one example of a change you could make.&amp;nbsp; First, add a LENGTH statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data word;&lt;/P&gt;
&lt;P&gt;length word $ 15;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then change the macro %let word= statement to a DATA step statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;word = "%scan(&amp;amp;name_list, &amp;amp;i)";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, turn on the proper option so you can see what the result is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options MPRINT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would be incredibly rare for a macro language programmer to do this in real life.&amp;nbsp; There is likely a better way to achieve your goal.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 19:57:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337534#M76655</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-02T19:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337536#M76656</link>
      <description>&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i first wrote a simple sas code &amp;amp; its output table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then i tried to write the same in macro. After writing macro i called the macro variable. but the out put result is different from normal sas code which i written first.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know macro process wont execute anything. we need to call it always to execute. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 20:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337536#M76656</guid>
      <dc:creator>ramya_sahu</dc:creator>
      <dc:date>2017-03-02T20:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337540#M76657</link>
      <description>&lt;P&gt;This statement in your macro code is not the same as a data step statement:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let word=%scan(&amp;amp;name_list,&amp;amp;i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above statement is assigning the value to a &lt;EM&gt;macro &lt;/EM&gt;variable called 'word' which is not the same as the &lt;EM&gt;data step&lt;/EM&gt; variable 'word'. Macro variables&amp;nbsp;do not get saved out to datasets. You cannot simply add % signs to all your data step code and expect it to behave the same. That is simply not what macros are &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These are the statements you need to change:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; name_list = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(Ramya Ranjan Sahu);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;word=scan(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;name_list"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;i);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;run; /* there is no statement such as %run */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 20:11:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337540#M76657</guid>
      <dc:creator>nehalsanghvi</dc:creator>
      <dc:date>2017-03-02T20:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337542#M76658</link>
      <description>Thanks sangvi. I m new to SAS. I m learning SAS macro now.&lt;BR /&gt;You can see the out put of my first SAS code.&lt;BR /&gt;&lt;BR /&gt;Can you please write me a SAS macro code which will give the same output?</description>
      <pubDate>Thu, 02 Mar 2017 20:17:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337542#M76658</guid>
      <dc:creator>ramya_sahu</dc:creator>
      <dc:date>2017-03-02T20:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337544#M76659</link>
      <description>&lt;P&gt;Not exactly what is happening. When you make a macro program, you are making a package of code that only writes SAS code. When the Macro program "executes" it executes BEFORE the compiler touches any data. So Macro program execution will not normally be able to "see" your data. The actual resolved code that the Macro program writes is the final program that is sent forward to the compiler. It is this RESOLVED code (without any macro references) that executes. So you need to be very clear that when you are calling or invoking a macro program, you are NOT interacting with any data in such as way that the MACRO program writes to the PDV. What is writing to the PDV in your program are the DATA, OUTPUT and assignment statements.&lt;BR /&gt;&lt;BR /&gt;cynthia&lt;BR /&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 20:20:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337544#M76659</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-03-02T20:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337545#M76660</link>
      <description>&lt;P&gt;I gave you the statements you needed to change in your macro portion. But here's the whole code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let i=1;
%let name_list = %str(Ramya Ranjan Sahu);

options mprint;

%macro Name;
data word2;
%do i = 1 %to %eval(%sysfunc(countw(&amp;amp;name_list))+1);
	Word=scan("&amp;amp;name_list",&amp;amp;i);  /* write value to a data step variable */
	%if &amp;amp;i=4 %then %do;
		Word="No More Words";
	%end;
	output;
%end;
format word $15.;
run;
%mend;

%name;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Mar 2017 20:20:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337545#M76660</guid>
      <dc:creator>nehalsanghvi</dc:creator>
      <dc:date>2017-03-02T20:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337554#M76666</link>
      <description>&lt;P&gt;Somewhat over complicated to date. Please consider:&lt;/P&gt;
&lt;PRE&gt;%macro name(Name_list);
   data Word;
      length word $ 25;
      do i=1 to countw("&amp;amp;Name_list")+1;
         Word=scan("&amp;amp;Name_list",i);
         if i=4 then Word="No More Words";
         Output;
      end;
   run;
%mend;
%name(Ramya Ranjan Sahu);&lt;/PRE&gt;
&lt;P&gt;Note that use of a parameter means that you can use the macro with a different list:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%Name( Singh Carram Marie John);&lt;/P&gt;
&lt;P&gt;Also you&amp;nbsp; should specifiy the length of the longest expected single WORD. Otherwise you end up with a 200 character length variable which may waste space and potentially cause some interesting issues if you ever use the || concatenation operator.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 20:34:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337554#M76666</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-02T20:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337712#M76743</link>
      <description>&lt;P&gt;Thanks Sanghvi;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code serving my purpose.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, in below step&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;%if&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;i&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;4&lt;/SPAN&gt; &lt;SPAN class="token macrostatement"&gt;%then&lt;/SPAN&gt; &lt;SPAN class="token macrostatement"&gt;%do&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;can we write something which will automatically detect 4 (since here three words i write 4)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any link which will be helpful to me where to use % &amp;amp; where not in macro?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 05:21:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337712#M76743</guid>
      <dc:creator>ramya_sahu</dc:creator>
      <dc:date>2017-03-03T05:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337713#M76744</link>
      <description>&lt;P&gt;hi balard, this code is serving my purose.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but, i still confused how this code given me result? because you have not ussed %do loop. you used only simple do loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;will macro work with simple do loop too?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 05:24:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337713#M76744</guid>
      <dc:creator>ramya_sahu</dc:creator>
      <dc:date>2017-03-03T05:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337719#M76747</link>
      <description>&lt;P&gt;I got my answer. thanks a lot.&lt;/P&gt;&lt;P&gt;Below code is working fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;options symbolgen mprint;&lt;BR /&gt;%macro Name(Name_List);&lt;BR /&gt;data word;&lt;BR /&gt;%do i = 1 %to %eval(%sysfunc(countw(&amp;amp;name_list))+1);&lt;BR /&gt;word=scan("&amp;amp;name_list",&amp;amp;i);&lt;BR /&gt;%if &amp;amp;i=%eval(%sysfunc(countw(&amp;amp;name_list))+1) %then %do; Word="No More Words";&lt;BR /&gt;%end;&lt;BR /&gt;output;&lt;BR /&gt;%end;&lt;BR /&gt;format word $15.;&lt;BR /&gt;%run;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;%name(Ramya Ranjan Sahu);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 06:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337719#M76747</guid>
      <dc:creator>ramya_sahu</dc:creator>
      <dc:date>2017-03-03T06:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337879#M76808</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt; Your question "will macro 'work' with simple do loop" implies to me that you think the macro program is doing all the work. It it not. &lt;BR /&gt;&lt;BR /&gt; The macro program is simply generating the code that will be sent to the compiler. &lt;BR /&gt;&lt;BR /&gt; If you run the program that was provided to you and turn on the MPRINT option, you will be able to see the code that goes forward to the compiler.&lt;BR /&gt;&lt;BR /&gt; I made a few slight changes to the program so that the stop value for the loop is set based on the COUNTW value -- that way, you do not have to hardcode the count value to create the last obs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here are some papers that may help: &lt;A href="https://support.sas.com/resources/papers/proceedings13/120-2013.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings13/120-2013.pdf&lt;/A&gt; and &lt;A href="http://www2.sas.com/proceedings/sugi28/056-28.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi28/056-28.pdf&lt;/A&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;BR /&gt; &lt;BR /&gt;cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7553i47D53EDEBF873E33/image-size/original?v=1.0&amp;amp;px=-1" alt="use_mprint.png" title="use_mprint.png" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 16:14:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337879#M76808</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-03-03T16:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337942#M76829</link>
      <description>&lt;P&gt;Thanks cynthia for your explanation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have small query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what is the diff. between %do loop &amp;amp; do loop.?&lt;/P&gt;&lt;P&gt;because i saw in some programs with % do loop &amp;amp; some with do loop.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 18:08:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/337942#M76829</guid>
      <dc:creator>ramya_sahu</dc:creator>
      <dc:date>2017-03-03T18:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/338035#M76852</link>
      <description>&lt;P&gt;%do is the MACRO loop and generates code that executes after the macro processor passes off for execution. This kind of loop could be involved with generated many lines of code either within a&amp;nbsp;data step, entire data steps&amp;nbsp;or procedure calls for each value of the loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DO loop manipulates data within a single&amp;nbsp;datastep for data step variables.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 21:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/338035#M76852</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-03T21:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Output statement in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/338094#M76877</link>
      <description>Hi:&lt;BR /&gt;  Please read both the papers from the links I posted. My paper explictly talks about the difference between %DO and the DATA step language DO.&lt;BR /&gt; &lt;BR /&gt;  And, as ballardw explains, the %DO loop is intended to be used inside a macro program for the sole purpose of controlling what program statements are generated to be sent to the compiler. &lt;BR /&gt;&lt;BR /&gt;The "regular" DATA step language DO loops are meant to interact with data and to impact data and to control the flow of processing in a DATA step program when the program executes.&lt;BR /&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Sat, 04 Mar 2017 05:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-statement-in-macro/m-p/338094#M76877</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-03-04T05:25:03Z</dc:date>
    </item>
  </channel>
</rss>

