<?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: Looping through passing parameters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Looping-through-passing-parameters/m-p/55178#M11756</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Think of the macro processor as a thing that just spits out code to the main SAS processor.&amp;nbsp; Thus, if there's structure to your code, then a macro may allow you to represent it more compactly rather than having to write all of it out long-hand, and is especially useful when you need to execute different code depending on certain conditions, or execute code a variable number of times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your example, if you want all the curvival curves in one dataset, then you don't need a macro loop.&amp;nbsp; Since you do want them in different datasets, then a macro would be useful.&amp;nbsp; Just beware that the macro do loop can only deal with integers, unlike data step do loops.&amp;nbsp; This will cause a bit of awkwardness.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All curves in one dataset:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; clv_months=36;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG style="color: navy; font-size: 9pt; background-color: white;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; curves(keep=ChurnRate time PC_live);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; ChurnRate = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.01&lt;/STRONG&gt; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.1&lt;/STRONG&gt; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;by&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.01&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pc_live = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SurviveRate = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; - ChurnRate;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; time = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0&lt;/STRONG&gt; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; &amp;amp;clv_months;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pc_live = pc_live * SurviveRate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; pc_live &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;7.5&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG style="color: navy; font-size: 9pt; background-color: white;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-size: 9pt; background-color: white; font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;A very literal translation of what was attempted:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG style="color: navy; font-size: 9pt; background-color: white;"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; curves( clv_months= );&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; i = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;1&lt;/STRONG&gt; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;10&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data churn&amp;amp;i(keep=ChurnRate time pc_live);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pc_live = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ChurnRate = &amp;amp;i / &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;100&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SurviveRate = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; - ChurnRate;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do time = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; to &amp;amp;clv_months;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pc_live = pc_live * SurviveRate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format pc_live &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;7.5&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG style="color: navy; font-size: 9pt; background-color: white;"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;curves&lt;/EM&gt;&lt;/STRONG&gt;( clv_months=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;36&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; )&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-size: 9pt; background-color: white; font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Of course this provides no control over the values of ChurnRate to iterate over, and should be changed to macro arguments:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG style="color: navy; font-size: 9pt; background-color: white;"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; curves( ChurnRate=, clv_months= );&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; i=1;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; rate=&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%scan&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;( &amp;amp;ChurnRate, &amp;amp;i, &lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;( ) );&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%do&lt;/SPAN&gt; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%while&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;( &amp;amp;rate~= );&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data churn&amp;amp;i(keep=ChurnRate time pc_live);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pc_live = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ChurnRate = &amp;amp;rate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SurviveRate = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; - ChurnRate;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do time = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; to &amp;amp;clv_months;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pc_live = pc_live * SurviveRate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format pc_live &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;7.5&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; i=&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%eval&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;(&amp;amp;i+1);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; rate=&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%scan&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;( &amp;amp;ChurnRate, &amp;amp;i, &lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;( ) );&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG style="color: navy; font-size: 9pt; background-color: white;"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;curves&lt;/EM&gt;&lt;/STRONG&gt;( ChurnRate=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.01&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.02&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.03&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.04&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.05&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.06&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.07&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.08&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.09&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;, clv_months=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;36&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; )&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 26 Aug 2011 15:56:40 GMT</pubDate>
    <dc:creator>DLing</dc:creator>
    <dc:date>2011-08-26T15:56:40Z</dc:date>
    <item>
      <title>Looping through passing parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-through-passing-parameters/m-p/55175#M11753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm &lt;STRONG&gt;very &lt;/STRONG&gt;new to SAS. I've tried reading through similar topics and it seems as though what I'm trying to do can't be done, but it seems like such an essential of programming that I'm struggling to get round it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to execute a macro, passing incrementing variables? This and varaints of it throw errors. I want to iteratively create a series of tables (I realise I've taken out the changing table names as I'm trying to simplfy my code to see where the errors are).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like using Call Execute might work, but it seems a bit clunky...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Let CLV_Months = 36;&lt;/P&gt;&lt;P&gt;Option MPRINT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%Macro CreateChurn(ChurnRate);&lt;/P&gt;&lt;P&gt;Data ChurnCurve;&lt;/P&gt;&lt;P&gt;PC_Live = 1;&lt;/P&gt;&lt;P&gt;Retain PC_Live;&lt;/P&gt;&lt;P&gt;do i = 0 to &amp;amp;CLV_Months;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PC_Live = PC_Live * (1-&amp;amp;&amp;amp;ChurnRate);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Output;&lt;/P&gt;&lt;P&gt;End;&lt;/P&gt;&lt;P&gt;Rename i = Month;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;%Mend CreateChurn;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data CCM;&lt;/P&gt;&lt;P&gt;Do MN = 1 to 10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;M1 = MN/100;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%CreateChurn(&amp;amp;M1);&lt;/P&gt;&lt;P&gt;End;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any assitance greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Aug 2011 09:40:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-through-passing-parameters/m-p/55175#M11753</guid>
      <dc:creator>robbane28</dc:creator>
      <dc:date>2011-08-26T09:40:56Z</dc:date>
    </item>
    <item>
      <title>Looping through passing parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-through-passing-parameters/m-p/55176#M11754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rob,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you've mixed up how the SAS macro processor works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your code you're running your macro inside a datastep.&amp;nbsp; I can understand why you'd have wanted to do this in order to run CreateChurn() with the values required.&amp;nbsp; However, SAS's macro's aren't like a function or procedure in a conventional programming language.&amp;nbsp; It's perhaps closer to the #define directive in C/C++ (although more complex) in that the macro pre-processor, which runs before your data steps are run, executes your macro code and returns the results as text which are then processed like any other code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This ends up meaning your code tries to run a data step inside another data step, which will not work or do as you expect.&amp;nbsp; (I tried to write up the equivalent output in code, but even a simple example ended up being quite long.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The two simplest solutions are to either use Call Execute as you mentioned, or simply move the "loop" function to the macro itself and run the macro once.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a simple example of the macro version, please see below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro runme();&lt;/P&gt;&lt;P&gt;%do i=1 %to 10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data test_&amp;amp;i.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var = i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%runme();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This uses the macro processer to run the loop from 1 to 10, and creates 10 datasets with one row named Test_1 to Test_10.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope that's enough to help you make some progress!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Aug 2011 12:53:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-through-passing-parameters/m-p/55176#M11754</guid>
      <dc:creator>DF</dc:creator>
      <dc:date>2011-08-26T12:53:50Z</dc:date>
    </item>
    <item>
      <title>Looping through passing parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-through-passing-parameters/m-p/55177#M11755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks ever so much. Great answer, I'm just trying to teach myself various techniques and doing such a thing with a macro felt obvious but clearly it doesn't work that way, internalising the loop or using execute seems to be perfect, thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Aug 2011 14:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-through-passing-parameters/m-p/55177#M11755</guid>
      <dc:creator>robbane28</dc:creator>
      <dc:date>2011-08-26T14:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through passing parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-through-passing-parameters/m-p/55178#M11756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Think of the macro processor as a thing that just spits out code to the main SAS processor.&amp;nbsp; Thus, if there's structure to your code, then a macro may allow you to represent it more compactly rather than having to write all of it out long-hand, and is especially useful when you need to execute different code depending on certain conditions, or execute code a variable number of times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your example, if you want all the curvival curves in one dataset, then you don't need a macro loop.&amp;nbsp; Since you do want them in different datasets, then a macro would be useful.&amp;nbsp; Just beware that the macro do loop can only deal with integers, unlike data step do loops.&amp;nbsp; This will cause a bit of awkwardness.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All curves in one dataset:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; clv_months=36;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG style="color: navy; font-size: 9pt; background-color: white;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; curves(keep=ChurnRate time PC_live);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; ChurnRate = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.01&lt;/STRONG&gt; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.1&lt;/STRONG&gt; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;by&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.01&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pc_live = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SurviveRate = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; - ChurnRate;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; time = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0&lt;/STRONG&gt; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; &amp;amp;clv_months;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pc_live = pc_live * SurviveRate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; pc_live &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;7.5&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG style="color: navy; font-size: 9pt; background-color: white;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-size: 9pt; background-color: white; font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;A very literal translation of what was attempted:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG style="color: navy; font-size: 9pt; background-color: white;"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; curves( clv_months= );&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; i = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;1&lt;/STRONG&gt; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;10&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data churn&amp;amp;i(keep=ChurnRate time pc_live);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pc_live = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ChurnRate = &amp;amp;i / &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;100&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SurviveRate = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; - ChurnRate;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do time = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; to &amp;amp;clv_months;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pc_live = pc_live * SurviveRate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format pc_live &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;7.5&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG style="color: navy; font-size: 9pt; background-color: white;"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;curves&lt;/EM&gt;&lt;/STRONG&gt;( clv_months=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;36&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; )&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-size: 9pt; background-color: white; font-family: courier new,courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Of course this provides no control over the values of ChurnRate to iterate over, and should be changed to macro arguments:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG style="color: navy; font-size: 9pt; background-color: white;"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; curves( ChurnRate=, clv_months= );&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; i=1;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; rate=&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%scan&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;( &amp;amp;ChurnRate, &amp;amp;i, &lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;( ) );&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%do&lt;/SPAN&gt; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%while&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;( &amp;amp;rate~= );&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data churn&amp;amp;i(keep=ChurnRate time pc_live);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pc_live = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ChurnRate = &amp;amp;rate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SurviveRate = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; - ChurnRate;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do time = &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; to &amp;amp;clv_months;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pc_live = pc_live * SurviveRate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format pc_live &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;7.5&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; i=&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%eval&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;(&amp;amp;i+1);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; rate=&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%scan&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;( &amp;amp;ChurnRate, &amp;amp;i, &lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;( ) );&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: blue; font-size: 9pt;"&gt;%end&lt;/SPAN&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG style="color: navy; font-size: 9pt; background-color: white;"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: courier new,courier; color: black; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;%&lt;STRONG&gt;&lt;EM&gt;curves&lt;/EM&gt;&lt;/STRONG&gt;( ChurnRate=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.01&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.02&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.03&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.04&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.05&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.06&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.07&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.08&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.09&lt;/STRONG&gt; &lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;0.1&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt;, clv_months=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 9pt; background-color: white;"&gt;36&lt;/STRONG&gt;&lt;SPAN style="background-color: white; color: black; font-size: 9pt;"&gt; )&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Aug 2011 15:56:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-through-passing-parameters/m-p/55178#M11756</guid>
      <dc:creator>DLing</dc:creator>
      <dc:date>2011-08-26T15:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through passing parameters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-through-passing-parameters/m-p/55179#M11757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so much, that really helps my thinking and I think the code should also help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks both again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Aug 2011 21:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-through-passing-parameters/m-p/55179#M11757</guid>
      <dc:creator>robbane28</dc:creator>
      <dc:date>2011-08-28T21:22:12Z</dc:date>
    </item>
  </channel>
</rss>

