<?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: Using the data step PUT function in a macro DO loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-the-data-step-PUT-function-in-a-macro-DO-loop/m-p/8158#M242</link>
    <description>All,&lt;BR /&gt;
&lt;BR /&gt;
The solution given by chang_y_chung worked like the proverbial charm !  The key was declaring xf as a local macro variable and using this statement within a macro to assign the appropriate value :&lt;BR /&gt;
   %let xf = %sysfunc(putn(&amp;amp;x, temp.));&lt;BR /&gt;
Thanks to all who responded  !&lt;BR /&gt;
Barry Walton</description>
    <pubDate>Wed, 06 Oct 2010 12:22:50 GMT</pubDate>
    <dc:creator>enginemane44</dc:creator>
    <dc:date>2010-10-06T12:22:50Z</dc:date>
    <item>
      <title>Using the data step PUT function in a macro DO loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-data-step-PUT-function-in-a-macro-DO-loop/m-p/8154#M238</link>
      <description>Hello all,&lt;BR /&gt;
I've been trying to get the following program working without much success.  Essentially, I want to run a macro %do loop with a data step WHERE statement to produce a custom report.  Here is the code (note the format fxx) :&lt;BR /&gt;
option symbolgen mprint mlogic;&lt;BR /&gt;
&lt;BR /&gt;
proc format;&lt;BR /&gt;
&lt;BR /&gt;
  value fxx 1 = 'Cold'&lt;BR /&gt;
                2 = 'Cool'&lt;BR /&gt;
	3 = 'Tepid'&lt;BR /&gt;
	4 = 'Warm'&lt;BR /&gt;
	5 = 'Hot';&lt;BR /&gt;
&lt;BR /&gt;
option formdlim = '  ';&lt;BR /&gt;
&lt;BR /&gt;
data one;&lt;BR /&gt;
input x;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1&lt;BR /&gt;
2&lt;BR /&gt;
2&lt;BR /&gt;
3&lt;BR /&gt;
5&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
%macro runit;&lt;BR /&gt;
%do i = 1 %to 5;&lt;BR /&gt;
 proc print data = one;&lt;BR /&gt;
    where x = &amp;amp;i;&lt;BR /&gt;
	format x fxx.;&lt;BR /&gt;
 title "Data set ONE from Macro when index is put((&amp;amp;i),fxx.))";&lt;BR /&gt;
 run;&lt;BR /&gt;
%end;&lt;BR /&gt;
%mend runit;&lt;BR /&gt;
&lt;BR /&gt;
%runit&lt;BR /&gt;
&lt;BR /&gt;
What I want is each where case to procduce the title :&lt;BR /&gt;
Data set ONE from Macro when index is tepid&lt;BR /&gt;
Instead SAS either displays the actual character string 'put(3,fxx) 'or says it can't&lt;BR /&gt;
find the put function.&lt;BR /&gt;
I can get the macro to run if I use :&lt;BR /&gt;
title 'Data set ONE with index &amp;amp;i - but then it displays just the number (e.g. 3), not the 'mapped' value (e.g. 'tepid').&lt;BR /&gt;
&lt;BR /&gt;
I tried %sysfunc, %eval, and even writing a macro to translate the number on the title statement - without success.&lt;BR /&gt;
Any ideas here ?&lt;BR /&gt;
Barry Walton&lt;BR /&gt;
Barry.Walton@millersville.edu&lt;BR /&gt;
Any ideas here ?</description>
      <pubDate>Tue, 28 Sep 2010 13:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-data-step-PUT-function-in-a-macro-DO-loop/m-p/8154#M238</guid>
      <dc:creator>enginemane44</dc:creator>
      <dc:date>2010-09-28T13:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using the data step PUT function in a macro DO loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-data-step-PUT-function-in-a-macro-DO-loop/m-p/8155#M239</link>
      <description>Only if you insist on using macros...&lt;BR /&gt;
[pre]&lt;BR /&gt;
   proc format;&lt;BR /&gt;
     value temp 1 = "Cold" 2 = "Cool" 3 = "Tepid"&lt;BR /&gt;
       4 = "Warm" 5 = "Hot";&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
   data one;&lt;BR /&gt;
     input x @@;&lt;BR /&gt;
   cards;&lt;BR /&gt;
   1 2 2 3 5&lt;BR /&gt;
   ;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
   %macro printf(x=);&lt;BR /&gt;
     %local xf;&lt;BR /&gt;
     %let xf = %sysfunc(putn(&amp;amp;x, temp.));&lt;BR /&gt;
     title "Data set one from macro where x=&amp;amp;xf";&lt;BR /&gt;
     proc print data=one;&lt;BR /&gt;
       where x = &amp;amp;x;&lt;BR /&gt;
       format x temp.;&lt;BR /&gt;
     run;&lt;BR /&gt;
     title;&lt;BR /&gt;
   %mend  printf;&lt;BR /&gt;
&lt;BR /&gt;
   %macro runit();&lt;BR /&gt;
     %local i;&lt;BR /&gt;
     %do i = 1 %to 5;&lt;BR /&gt;
       %printf(x=&amp;amp;i)&lt;BR /&gt;
     %end;&lt;BR /&gt;
   %mend runit;&lt;BR /&gt;
&lt;BR /&gt;
   %runit()&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 28 Sep 2010 13:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-data-step-PUT-function-in-a-macro-DO-loop/m-p/8155#M239</guid>
      <dc:creator>chang_y_chung_hotmail_com</dc:creator>
      <dc:date>2010-09-28T13:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using the data step PUT function in a macro DO loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-data-step-PUT-function-in-a-macro-DO-loop/m-p/8156#M240</link>
      <description>The OP's SAS program is solid except for the TITLE statement, as shown in post-reply above - the %SYSFUNC(...) needs to be used.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 28 Sep 2010 13:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-data-step-PUT-function-in-a-macro-DO-loop/m-p/8156#M240</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-09-28T13:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using the data step PUT function in a macro DO loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-data-step-PUT-function-in-a-macro-DO-loop/m-p/8157#M241</link>
      <description>Maybe you don't need macros at all.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
options byline=0;&lt;BR /&gt;
title "Data set ONE from Macro when index is #byval1";&lt;BR /&gt;
proc print data = one;&lt;BR /&gt;
   by X;&lt;BR /&gt;
   var x;&lt;BR /&gt;
   format x fxx.;&lt;BR /&gt;
   run;&lt;BR /&gt;
options byline=1;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 28 Sep 2010 13:52:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-data-step-PUT-function-in-a-macro-DO-loop/m-p/8157#M241</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-09-28T13:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using the data step PUT function in a macro DO loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-data-step-PUT-function-in-a-macro-DO-loop/m-p/8158#M242</link>
      <description>All,&lt;BR /&gt;
&lt;BR /&gt;
The solution given by chang_y_chung worked like the proverbial charm !  The key was declaring xf as a local macro variable and using this statement within a macro to assign the appropriate value :&lt;BR /&gt;
   %let xf = %sysfunc(putn(&amp;amp;x, temp.));&lt;BR /&gt;
Thanks to all who responded  !&lt;BR /&gt;
Barry Walton</description>
      <pubDate>Wed, 06 Oct 2010 12:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-data-step-PUT-function-in-a-macro-DO-loop/m-p/8158#M242</guid>
      <dc:creator>enginemane44</dc:creator>
      <dc:date>2010-10-06T12:22:50Z</dc:date>
    </item>
  </channel>
</rss>

