<?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: How to increase a columns value by 1 based on it's max value? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-a-columns-value-by-1-based-on-it-s-max-value/m-p/747389#M29486</link>
    <description>I'm sorry. What I meant by increasing the value by 1 based on the max value, is to increase the value by 1 in the first row in each group and then for that group the value keeps getting increased by 1 from there on.</description>
    <pubDate>Fri, 11 Jun 2021 16:05:56 GMT</pubDate>
    <dc:creator>cosmid</dc:creator>
    <dc:date>2021-06-11T16:05:56Z</dc:date>
    <item>
      <title>How to increase a columns value by 1 based on it's max value?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-a-columns-value-by-1-based-on-it-s-max-value/m-p/747388#M29485</link>
      <description>&lt;P&gt;If I have a data like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  input class x;
datalines;
1 1
1 2
2 1
2 2
2 3
3 5
3 6
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And I want the output to be:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;class x
  1     3
  1     4
  2     4
  2     5
  2     6
  3     7
  3     8&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I can get the max number from each class but I don't know how to proceed to the next step by increasing them by 1.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select max(x) into :max_val
  from sample
  group by class;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Jun 2021 16:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-increase-a-columns-value-by-1-based-on-it-s-max-value/m-p/747388#M29485</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2021-06-11T16:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to increase a columns value by 1 based on it's max value?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-a-columns-value-by-1-based-on-it-s-max-value/m-p/747389#M29486</link>
      <description>I'm sorry. What I meant by increasing the value by 1 based on the max value, is to increase the value by 1 in the first row in each group and then for that group the value keeps getting increased by 1 from there on.</description>
      <pubDate>Fri, 11 Jun 2021 16:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-increase-a-columns-value-by-1-based-on-it-s-max-value/m-p/747389#M29486</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2021-06-11T16:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to increase a columns value by 1 based on it's max value?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-a-columns-value-by-1-based-on-it-s-max-value/m-p/747392#M29487</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=sample noprint NWAY;
class class;
var x;
output out=maxes N=N Max = Max;
run;

data want;
set maxes;

do i=1 to n;
x = max + i ;
output;
end;
&lt;BR /&gt;keep class x;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253026"&gt;@cosmid&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;If I have a data like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  input class x;
datalines;
1 1
1 2
2 1
2 2
2 3
3 5
3 6
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And I want the output to be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;class x
  1     3
  1     4
  2     4
  2     5
  2     6
  3     7
  3     8&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I can get the max number from each class but I don't know how to proceed to the next step by increasing them by 1.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select max(x) into :max_val
  from sample
  group by class;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 16:12:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-increase-a-columns-value-by-1-based-on-it-s-max-value/m-p/747392#M29487</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-11T16:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to increase a columns value by 1 based on it's max value?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-a-columns-value-by-1-based-on-it-s-max-value/m-p/747422#M29488</link>
      <description>Wow! I didn't know you can use a proc means like that! Really learned a lot, thank you!&lt;BR /&gt;&lt;BR /&gt;This works great for the sample data! Is there a way to keep other columns while increasing the value by 1? It seems the proc freq dropped other columns when I test it.</description>
      <pubDate>Fri, 11 Jun 2021 17:22:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-increase-a-columns-value-by-1-based-on-it-s-max-value/m-p/747422#M29488</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2021-06-11T17:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to increase a columns value by 1 based on it's max value?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-a-columns-value-by-1-based-on-it-s-max-value/m-p/747443#M29489</link>
      <description>You can look at the ID statement in PROC MEANS to keep other variables or you can remerge it with your original data set to keep other columns. &lt;BR /&gt;There is no PROC FREQ in my code.</description>
      <pubDate>Fri, 11 Jun 2021 17:43:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-increase-a-columns-value-by-1-based-on-it-s-max-value/m-p/747443#M29489</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-11T17:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to increase a columns value by 1 based on it's max value?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-increase-a-columns-value-by-1-based-on-it-s-max-value/m-p/747533#M29490</link>
      <description>&lt;PRE&gt;data sample;
  input class x;
datalines;
1 1
1 2
2 1
2 2
2 3
3 5
3 6
;
data sample;
 set sample;
 by class;
 if first.class then n=0;
 n+1;
run;
proc sql;
create table want as
select *,sum(n,max(x)) as want
 from sample
  group by class
   order by 1,2;
quit;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Jun 2021 12:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-increase-a-columns-value-by-1-based-on-it-s-max-value/m-p/747533#M29490</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-06-12T12:08:15Z</dc:date>
    </item>
  </channel>
</rss>

