<?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: Find month where get max value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-month-where-get-max-value/m-p/946466#M370654</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input CustID  YYYYMM  $ month wealth obligo;
cards;
1111 202401 1 100 20
1111 202402 2 140 80
1111 202403 3 180 15
1111 202404 4 110 12
1111 202405 5 100 12
1111 202406 6 130 10
2222 202401 1 300 13
2222 202402 2 140 14
2222 202403 3 180 15
2222 202404 4 110 12
2222 202405 5 100 40
2222 202406 6 130 10
3333 202401 1 300 10
3333 202402 2 140 14
3333 202403 3 180 15
3333 202404 4 110 40
3333 202405 5 100 40
3333 202406 6 300 10
;
Run;
data want;
do until(last.CustID);
 set have;
 by CustID;
 if wealth&amp;gt;max_wealth then do;month_max_wealth=month;max_wealth=wealth;end;  
 if obligo&amp;gt;max_obligo then do;month_max_obligo=month;max_obligo=obligo;end;  
end;
keep CustID max_: month_:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 07 Oct 2024 01:45:50 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2024-10-07T01:45:50Z</dc:date>
    <item>
      <title>Find month where get max value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-month-where-get-max-value/m-p/946458#M370650</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;For each customer have 6 rows with information of 6 months on wealth and obligo.&lt;/P&gt;
&lt;P&gt;Target-&lt;/P&gt;
&lt;P&gt;to calculate for each customer which month (1/2/3/4/5/6) provide max wealth&lt;/P&gt;
&lt;P&gt;to calculate for each customer which month (1/2/3/4/5/6) provide max obligo&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what is the way to create wanted data set from have data set?&lt;/P&gt;
&lt;P&gt;note- IF multiple months have max value then the max month will be the earliest&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
input CustID  YYYYMM month wealth obligo;
cards;
1111 202401 1 100 20
1111 202402 2 140 80
1111 202403 3 180 15
1111 202404 4 110 12
1111 202405 5 100 12
1111 202406 6 130 10
2222 202401 1 300 13
2222 202402 2 140 14
2222 202403 3 180 15
2222 202404 4 110 12
2222 202405 5 100 40
2222 202406 6 130 10
3333 202401 1 300 10
3333 202402 2 140 14
3333 202403 3 180 15
3333 202404 4 110 40
3333 202405 5 100 40
3333 202406 6 300 10
;
Run;


data wanted;
input CustID month_max_wealth month_max_obligo;
cards;
1111 3 2
2222 1 5
3333 1 4
;
Run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 06 Oct 2024 20:15:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-month-where-get-max-value/m-p/946458#M370650</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-10-06T20:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Find month where get max value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-month-where-get-max-value/m-p/946459#M370651</link>
      <description>&lt;P&gt;PROC SUMMARY is the way&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
    class custid;
    var wealth obligo;
    output out=want maxid(wealth(month) obligo(month))=max_wealth max_obligo;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 06 Oct 2024 20:58:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-month-where-get-max-value/m-p/946459#M370651</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-10-06T20:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: Find month where get max value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-month-where-get-max-value/m-p/946466#M370654</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input CustID  YYYYMM  $ month wealth obligo;
cards;
1111 202401 1 100 20
1111 202402 2 140 80
1111 202403 3 180 15
1111 202404 4 110 12
1111 202405 5 100 12
1111 202406 6 130 10
2222 202401 1 300 13
2222 202402 2 140 14
2222 202403 3 180 15
2222 202404 4 110 12
2222 202405 5 100 40
2222 202406 6 130 10
3333 202401 1 300 10
3333 202402 2 140 14
3333 202403 3 180 15
3333 202404 4 110 40
3333 202405 5 100 40
3333 202406 6 300 10
;
Run;
data want;
do until(last.CustID);
 set have;
 by CustID;
 if wealth&amp;gt;max_wealth then do;month_max_wealth=month;max_wealth=wealth;end;  
 if obligo&amp;gt;max_obligo then do;month_max_obligo=month;max_obligo=obligo;end;  
end;
keep CustID max_: month_:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Oct 2024 01:45:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-month-where-get-max-value/m-p/946466#M370654</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-10-07T01:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: Find month where get max value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-month-where-get-max-value/m-p/946492#M370656</link>
      <description>&lt;P&gt;Maxim 7 at work. Very nice.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2024 09:45:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-month-where-get-max-value/m-p/946492#M370656</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-10-07T09:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Find month where get max value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-month-where-get-max-value/m-p/946496#M370657</link>
      <description>&lt;P&gt;And Maxim 14!&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2024 10:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-month-where-get-max-value/m-p/946496#M370657</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-10-07T10:00:45Z</dc:date>
    </item>
  </channel>
</rss>

