<?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: Macro with DO UNTIL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548379#M152056</link>
    <description>&lt;P&gt;Okay, thanks again!&lt;/P&gt;</description>
    <pubDate>Thu, 04 Apr 2019 02:17:37 GMT</pubDate>
    <dc:creator>eabc0351</dc:creator>
    <dc:date>2019-04-04T02:17:37Z</dc:date>
    <item>
      <title>Macro with DO UNTIL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548365#M152046</link>
      <description>&lt;P&gt;Hello. Please see below code. I need to run this on 20 variables, from Yr1 to Yr20. Tried to make this into a macro, but it didn't work. Is it possible to turn this into a macro so it doesn't require re-running it for all 20 variables.&amp;nbsp; Thank you.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
do until (last.ID);
	set have;
	by ID;
	highest=max(highest, Yr1);
end;
do until (last.ID);
	set have;
	by ID;
	Yr1=highest;
output;
end;
drop highest;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Apr 2019 01:05:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548365#M152046</guid>
      <dc:creator>eabc0351</dc:creator>
      <dc:date>2019-04-04T01:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with DO UNTIL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548366#M152047</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* 
wrap your code inside this macro do loop.
Make sure you replace Yr1 to Yr&amp;amp;i  
and data want to 
data want&amp;amp;i; 

*/

%macro run20x;
%do i=1 %to 20;

* put your code here ;

%end;
%mend;

%run20x;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Apr 2019 01:17:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548366#M152047</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2019-04-04T01:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with DO UNTIL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548367#M152048</link>
      <description>&lt;P&gt;Thank you. It was the&amp;nbsp;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #008000; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 16.8px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;data want&amp;amp;i; &lt;/SPAN&gt;part that I forgot. Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 01:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548367#M152048</guid>
      <dc:creator>eabc0351</dc:creator>
      <dc:date>2019-04-04T01:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with DO UNTIL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548369#M152050</link>
      <description>&lt;P&gt;You're welcome, but I would suggest you re-think your approach.&amp;nbsp; You many not need 20 variables.&amp;nbsp; Also use the power of SAS to find max values, perhaps Proc Summary&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 01:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548369#M152050</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2019-04-04T01:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with DO UNTIL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548374#M152053</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/78622"&gt;@ghosh&lt;/a&gt;thanks, will consider that. One more question. The macro creates 20 datasets from want&amp;amp;i. Is there anyway not to create 20, but to rewrite over the same one - similar to a datastep?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 01:56:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548374#M152053</guid>
      <dc:creator>eabc0351</dc:creator>
      <dc:date>2019-04-04T01:56:54Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with DO UNTIL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548378#M152055</link>
      <description>Well if you just use "data want", it will overwrite.&lt;BR /&gt;&lt;BR /&gt;But I am sure that's not what you want. Better to create an ID variable and increment it for each iteration.</description>
      <pubDate>Thu, 04 Apr 2019 02:09:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548378#M152055</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2019-04-04T02:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with DO UNTIL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548379#M152056</link>
      <description>&lt;P&gt;Okay, thanks again!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 02:17:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548379#M152056</guid>
      <dc:creator>eabc0351</dc:creator>
      <dc:date>2019-04-04T02:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with DO UNTIL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548383#M152058</link>
      <description>&lt;P&gt;What are you trying to create?&lt;/P&gt;
&lt;P&gt;Are you just trying to find the maximum value for 20 variables?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have;
  by id;
  var yr1-yr20;
  output out=want max=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Apr 2019 02:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548383#M152058</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-04T02:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with DO UNTIL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548446#M152085</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;.&amp;nbsp;Here's what I'm trying to do with the DO UNTIL code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have
input id$2. Yr1 Yr2 ... Yr20 ;
datalines;
1 4 . ... 3
1 . 2 ... .
1 . . ... .      
2 . . ... 2
2 1 . ... .
3 . . ... .
3 . 3 ... 4
4 . 4 ... .
4 . . ... .
4 2 . ... .
4 . . ... .
;

data want
input id$2. Yr1 Yr2 ... Yr20 ;
datalines;
1 4 2 ... 3     
2 1 . ... 2
3 . 3 ... 4
4 2 4 ... .
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;I get data want through two steps, which are:&lt;BR /&gt;1) Use DO UNTIL to replace all values within ID by group to highest value. For example:&lt;BR /&gt;datastep1&lt;BR /&gt;input id$2. Yr1 Yr2 ... Yr20 ;&lt;BR /&gt;datalines;&lt;BR /&gt;1 4 2 ... 3&lt;BR /&gt;1 4 2 ... 3&lt;BR /&gt;1 4 2 ... 3&lt;BR /&gt;2 1 . ... 2&lt;BR /&gt;2 1 . ... 2&lt;BR /&gt;run;&lt;BR /&gt;2) Then collapse on id to get data want&lt;/P&gt;&lt;P&gt;If there is a better way to do this, I'm all ears. Maybe proc sql select case when?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 10:18:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548446#M152085</guid>
      <dc:creator>eabc0351</dc:creator>
      <dc:date>2019-04-04T10:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with DO UNTIL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548477#M152094</link>
      <description>&lt;P&gt;To find the MAX (or many other statistics) use PROC SUMMARY.&amp;nbsp; I posted example already.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 12:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548477#M152094</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-04T12:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: Macro with DO UNTIL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548482#M152096</link>
      <description>&lt;P&gt;Thanks to you both &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/78622"&gt;@ghosh&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;. This will save much time.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 13:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-with-DO-UNTIL/m-p/548482#M152096</guid>
      <dc:creator>eabc0351</dc:creator>
      <dc:date>2019-04-04T13:17:27Z</dc:date>
    </item>
  </channel>
</rss>

