<?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: Iterative codes - macro may be appropriate? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843683#M333535</link>
    <description>&lt;P&gt;Is that second column supposed to be a DATE value?&amp;nbsp; Which dates are those?&amp;nbsp; Is the second value supposed to mean April fools day ? or the fourth day of January?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are some of the cells using subtraction and some are using addition?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the meaning of the column header 'date diff'?&amp;nbsp; Is that a difference in dates?&amp;nbsp; So 92 means about 3 months?&amp;nbsp; Or is a difference in the VALUES.&amp;nbsp; The later makes more sense in terms of the equations you have the last column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why does one cell have just a hyphen in it? Is that supposed by a missing value?&amp;nbsp; Or some type of special missing that is different than the other missing values?&lt;/P&gt;</description>
    <pubDate>Thu, 10 Nov 2022 20:48:25 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-11-10T20:48:25Z</dc:date>
    <item>
      <title>Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843680#M333532</link>
      <description>&lt;P&gt;Dataset looks like the following. There are 1000's of IDs and 100,000's of observations.&amp;nbsp;&lt;/P&gt;&lt;P&gt;'Wanted Value' is the desired output using the variable "Value". The number of observations for ID is not constant, normally between 5 and 30. There could be intermittent missing values in between which need to be repopulated plus or minus the date difference, depending upon the moving forward vs backward. Missing values are labelled as ".".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;TD&gt;2&lt;/TD&gt;&lt;TD&gt;4/1/2003&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;90&lt;/TD&gt;&lt;TD&gt;600+92+90&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;7/1/2003&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;91&lt;/TD&gt;&lt;TD&gt;600+92+90+91&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;10/1/2003&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;92&lt;/TD&gt;&lt;TD&gt;600+92+90+91+92&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1/1/2004&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;92&lt;/TD&gt;&lt;TD&gt;600+92+90+91+92+92&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;4/1/2004&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;91&lt;/TD&gt;&lt;TD&gt;600+92+90+91+92+92+91&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 10 Nov 2022 20:12:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843680#M333532</guid>
      <dc:creator>SAS_nova</dc:creator>
      <dc:date>2022-11-10T20:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843681#M333533</link>
      <description>&lt;P&gt;So the final number should be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Value&lt;/TD&gt;&lt;TD&gt;Date Diff&lt;/TD&gt;&lt;TD&gt;Wanted Value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1/1/2000&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;TD&gt;326&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;and so on.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 20:18:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843681#M333533</guid>
      <dc:creator>SAS_nova</dc:creator>
      <dc:date>2022-11-10T20:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843683#M333535</link>
      <description>&lt;P&gt;Is that second column supposed to be a DATE value?&amp;nbsp; Which dates are those?&amp;nbsp; Is the second value supposed to mean April fools day ? or the fourth day of January?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are some of the cells using subtraction and some are using addition?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the meaning of the column header 'date diff'?&amp;nbsp; Is that a difference in dates?&amp;nbsp; So 92 means about 3 months?&amp;nbsp; Or is a difference in the VALUES.&amp;nbsp; The later makes more sense in terms of the equations you have the last column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why does one cell have just a hyphen in it? Is that supposed by a missing value?&amp;nbsp; Or some type of special missing that is different than the other missing values?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 20:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843683#M333535</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-10T20:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843688#M333536</link>
      <description>&lt;P&gt;You have to explain how "Wanted Value" is computed from the rest of the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We can't possibly tell you if a macro may be appropriate until we understand this (although it sure doesn't look like a macro is needed right now).&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 21:46:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843688#M333536</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-10T21:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843692#M333540</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436984"&gt;@SAS_nova&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'Wanted Value' is the desired output using the variable "Value". You need to provide RULES for how Value is calculated. Examples I can program to exactly match your shown "need" but without a set of rules on how things are calculated the code is very unlikely to work for any other data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"There could be intermittent missing values in between which need to be repopulated plus or minus the date difference, depending upon the moving forward vs backward." What is "repopulated"? Into what variable? Using what rules? What does "forward" mean? What does "backward" mean? How do we know when to apply forward and when backward?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It appears that "date diff" is the number of days from the previous date value, is that interpretation correct?&lt;/P&gt;
&lt;P&gt;If so I am wondering what the "value" is if you are adding/subtracting days with that value.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 21:58:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843692#M333540</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-11-10T21:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843694#M333542</link>
      <description>&lt;P&gt;I've stared at this for a while, and I think I'm starting to see the pattern.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the data you HAVE is the table with first four columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data you WANT is the same table with the 5th column, WantedValue, added.&amp;nbsp; Is that right?&amp;nbsp; And the values of WantedValues is the result of evaluating the expression you entered (e.g.&amp;nbsp;&lt;SPAN&gt;600-92-91-91=326, so you want the value 326 for the first row).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It looks to me like your WantedValue is basically an accumulator.&amp;nbsp; Where if VALUE is nonmissing, then WantedValue=VALUE.&amp;nbsp; Else if Value is missing then WantedValue=WantedValue (retained)+Date Diff.&amp;nbsp; Is that right?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;The only tricky part is that you don't have an initial value for Wanted Value. You need to compute the initial WantedValue for each ID as the first non-missing VALUE for that ID minus the sum of all the DateDIff values before that record.&amp;nbsp; I think. : )&lt;BR /&gt;&lt;BR /&gt;That said, can you describe in words what you are doing?&amp;nbsp; The dates are clearly the start of each quarter.&amp;nbsp; DateDiff is number of days in a quarter.&amp;nbsp; What is the meaning of VALUE?&amp;nbsp; If this is all just date arithmetic, there is probably a better way to get what you want.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Also, could you please post your HAVE data as code (i.e. a DATA step with cards statement)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But to answer your question, no, it doesn't look like a macro problem.&amp;nbsp; There is likely a DATA step approach to solving this.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 23:09:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843694#M333542</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-11-10T23:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843695#M333543</link>
      <description>I'm wondering why if datediff is in fact a calculated date difference why one would store that instead of calculating it when it is needed.</description>
      <pubDate>Thu, 10 Nov 2022 23:15:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843695#M333543</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2022-11-10T23:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843702#M333544</link>
      <description>&lt;P&gt;Is that second column supposed to be a DATE value?&amp;nbsp; Which dates are those?&amp;nbsp; Is the second value supposed to mean April fools day ? or the fourth day of January?&lt;/P&gt;&lt;P&gt;-- 1 date to 2 date is always about 3 months (April, 1st - Jan 1st and so on)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why are some of the cells using subtraction and some are using addition?&lt;/P&gt;&lt;P&gt;-- if 'wanted value' back in time then subtraction is needed. Opposite for forward in time i.e. addition&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the meaning of the column header 'date diff'?&amp;nbsp; Is that a difference in dates?&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- Yes: Date2 - Date1&lt;/P&gt;&lt;P&gt;So 92 means about 3 months?&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Yes&lt;/P&gt;&lt;P&gt;Or is a difference in the VALUES.&amp;nbsp; The later makes more sense in terms of the equations you have the last column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why does one cell have just a hyphen in it? Is that supposed by a missing value?&amp;nbsp; Or some type of special missing that is different than the other missing values?&lt;/P&gt;&lt;P&gt;- that should be 0 or no values. Because of Date1 - (no previous date).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 23:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843702#M333544</guid>
      <dc:creator>SAS_nova</dc:creator>
      <dc:date>2022-11-10T23:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843706#M333546</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/6401"&gt;@HB&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I'm wondering why if datediff is in fact a calculated date difference why one would store that instead of calculating it when it is needed.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yep, part of the next round of clarifications.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 00:26:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843706#M333546</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-11-11T00:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843725#M333554</link>
      <description>&lt;P&gt;The proper way to present example data is a DATA step with DATALINES, see here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id $ date :yymmdd10. value date_diff;
format date yymmdd10.;
datalines;
1 2000-01-01 . .
1 2000-04-01 . 91
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Variable types, attributes and raw contents are clear.&lt;/P&gt;
&lt;P&gt;Dates in YMD order are unambiguous.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please expand on this example. Make changes to the code where necessary (where my &lt;EM&gt;assumptions&lt;/EM&gt; do not reflect your real situation).&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 07:39:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843725#M333554</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-11T07:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843743#M333562</link>
      <description>&lt;P&gt;Explain this part:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are some of the cells using subtraction and some are using addition?&lt;/P&gt;
&lt;P&gt;-- if 'wanted value' back in time then subtraction is needed. Opposite for forward in time i.e. addition&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would we know if your wanted value is back in time or forward in time? Back in time or forward in time from what point in time?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 11:25:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843743#M333562</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-11T11:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843755#M333566</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards expandtabs truncover;
input ID Date :$20. Value DateDiff;
cards; 
1 1/1/2000 . . 
1 4/1/2000 . 91 
1 7/1/2000 . 91 
1 10/1/2000 . 92 
1 1/1/2001 600 92 
1 4/1/2001 600 90 
1 7/1/2001 . 91 
1 10/1/2001 730 92 
2 1/1/2002 . 92 
2 4/1/2002 550 90 
2 7/1/2002 . 91 
2 10/1/2002 600 92 
2 1/1/2003 . 92 
2 4/1/2003 . 90 
2 7/1/2003 . 91 
2 10/1/2003 . 92 
2 1/1/2004 . 92 
2 4/1/2004 . 91
;

data temp;
 set have;
 n+1;
 if missing(DateDiff) then DateDiff=0;
run;
data temp1;
do until(last.id);
 set temp;
 by id notsorted;
 if not missing(value) then want=value;
  else want=want+DateDiff;
  output;
end;
run;
proc sort data=temp1 out=temp2;
by descending n;
run;
data temp3;
do until(last.id);
 set temp2;
 by id notsorted;
 if not missing(want) then want2=want;
  else want2=want2-DateDiff;
  output;
end;
run;
proc sort data=temp3 out=want(drop=want n);
by n;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Nov 2022 11:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843755#M333566</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-11-11T11:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843757#M333567</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436984"&gt;@SAS_nova&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why does one cell have just a hyphen in it? Is that supposed by a missing value?&amp;nbsp; Or some type of special missing that is different than the other missing values?&lt;/P&gt;
&lt;P&gt;- that should be 0 or no values. Because of Date1 - (no previous date).&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since you are calculating stuff BY ID, shouldn't DateDIff be 0 (or null) for the first record of each ID? Meaning ID=2 Date=1/1/2002 should have DateDiff=0 not 92? Or alternatively, maybe DateDiff should have a value for the first record, because you know how many days were in that quarter, even if you don't have a date value in your data for the prior quarter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But again, more big picture words about the purpose of this code would be helpful.&amp;nbsp; Also curious that the meaning of VALUE is.&amp;nbsp; I assume it's unit is days, since you are subtracting from and adding days to it.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 11:59:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843757#M333567</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-11-11T11:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843759#M333568</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Explain this part:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are some of the cells using subtraction and some are using addition?&lt;/P&gt;
&lt;P&gt;-- if 'wanted value' back in time then subtraction is needed. Opposite for forward in time i.e. addition&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would we know if your wanted value is back in time or forward in time? Back in time or forward in time from what point in time?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think the reference point intended is, for each ID, the first record where VALUE is not null.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 12:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843759#M333568</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-11-11T12:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843776#M333575</link>
      <description>Yes, that can done using the calculated date difference</description>
      <pubDate>Fri, 11 Nov 2022 13:03:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843776#M333575</guid>
      <dc:creator>SAS_nova</dc:creator>
      <dc:date>2022-11-11T13:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: Iterative codes - macro may be appropriate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843819#M333590</link>
      <description>&lt;P&gt;Thank you all for your help! Apologies for not posting the problem clearly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 16:12:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterative-codes-macro-may-be-appropriate/m-p/843819#M333590</guid>
      <dc:creator>SAS_nova</dc:creator>
      <dc:date>2022-11-11T16:12:38Z</dc:date>
    </item>
  </channel>
</rss>

