<?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: Age grouping in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/869105#M343316</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440493"&gt;@PrinceAde&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I did as you said using if else condition to create a new variable agegroup;&lt;/P&gt;
&lt;P&gt;&amp;lt;65&lt;/P&gt;
&lt;P&gt;&amp;gt;=65&lt;/P&gt;
&lt;P&gt;as agroupx then proc freq&lt;/P&gt;
&lt;P&gt;&amp;lt;75&lt;/P&gt;
&lt;P&gt;&amp;gt;=75&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as agegroupy then proc freq.&lt;/P&gt;
&lt;P&gt;Thank you very much. Very helpful.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But I did not say to create new variables. I specifically said use formats. Part of the purpose of having these discussions is not just to provide an answer, but to point you in the direction of better methods. Formats are better for a lot of reasons than creating new variables, and apparently despite formats being mentioned by many people, you chose not to use this better method.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Apr 2023 13:08:07 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-04-11T13:08:07Z</dc:date>
    <item>
      <title>Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868750#M343190</link>
      <description>I'm trying to group derive age group as shown below.&lt;BR /&gt;&amp;lt;65&lt;BR /&gt;&amp;gt;=65&lt;BR /&gt;&amp;lt;75&lt;BR /&gt;&amp;gt;=75&lt;BR /&gt;data ydata;&lt;BR /&gt;set mdata;&lt;BR /&gt;if age &amp;lt; 65 then age_group = "&amp;lt;65";&lt;BR /&gt;else if age &amp;gt;= 65 then age_group = "&amp;gt;=65";&lt;BR /&gt;else if age &amp;lt; 75 then age_group = "&amp;lt;75";&lt;BR /&gt;else if age &amp;gt;= 75 then age_group = "&amp;gt;=75";&lt;BR /&gt;run;&lt;BR /&gt;When I ran this code it as I expected ignored the last two statements.&lt;BR /&gt;Is it possible to like that at all?&lt;BR /&gt;What can I do?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 09 Apr 2023 10:19:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868750#M343190</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-04-09T10:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868754#M343191</link>
      <description>&lt;P&gt;It ignores the last two groupings because your logic is incorrect. After the first two tests, the person's age is either &amp;lt;65 or &amp;gt;=65, one of those two conditions has to be true and so the remaining tests are not performed. But we're still left guessing as to what you DO want out of this data — you haven't told us. So a guess: perhaps you want something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if age &amp;lt; 65 then age_group = "&amp;lt;65";
else if age &amp;gt;= 65 and age&amp;lt;75 then age_group = "65-75";
else if age &amp;gt;= 75 then age_group = "&amp;gt;=75";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A better solution is to use custom formats and then use the formats in your analysis; rather than create a new variable which is a character string. Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value agef low-&amp;lt;65='&amp;lt;65' 65-&amp;lt;75='65-75' 75-high='&amp;gt;=75';
run;

proc means data=have;
    class age;
    format age agef.;
    var whatever;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2023 17:06:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868754#M343191</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-09T17:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868755#M343192</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440493"&gt;@PrinceAde&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS Formats are the perfect solution to this.&lt;/P&gt;
&lt;P&gt;Check this paper for ilustartion&amp;nbsp;&lt;A title="The Power of the FORMAT Procedure" href="https://support.sas.com/resources/papers/proceedings/proceedings/sugi31/249-31.pdf" target="_blank" rel="noopener"&gt;The Power of the FORMAT Procedure&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2023 10:28:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868755#M343192</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2023-04-09T10:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868756#M343193</link>
      <description>&lt;P&gt;I can only reinforce what has already been said: use a format.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2023 10:32:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868756#M343193</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-04-09T10:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868791#M343216</link>
      <description>&lt;P&gt;You have another syntax issue involved related to the length of the result variable.&lt;/P&gt;
&lt;P&gt;If you run:&lt;/P&gt;
&lt;PRE&gt;data example;
 input age;
if age &amp;lt; 65 then age_group = "&amp;lt;65";
else if age &amp;gt;= 65 then age_group = "&amp;gt;=65";
else if age &amp;lt; 75 then age_group = "&amp;lt;75";
else if age &amp;gt;= 75 then age_group = "&amp;gt;=75";
datalines;
63
64
65
66
67
;


proc print data=example;
run;&lt;/PRE&gt;
&lt;P&gt;You will get a result of&lt;/P&gt;
&lt;PRE&gt;Obs age age_group 
1 63 &amp;lt;65 
2 64 &amp;lt;65 
3 65 &amp;gt;=6 
4 66 &amp;gt;=6 
5 67 &amp;gt;=6 
&lt;/PRE&gt;
&lt;P&gt;Why "&amp;gt;=6" you may ask? You did not define length for your Age_group variable. So the first use of the variable in the assignment:&lt;/P&gt;
&lt;PRE&gt;if age &amp;lt; 65 then age_group = "&amp;lt;65";&lt;/PRE&gt;
&lt;P&gt;established a length of three characters, enough to hold &amp;lt;65.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is another thing that formats will avoid. The groups created by formats will be honored by reporting and analysis procedures and in most places for graphing. So you don't even have to add a variable at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2023 17:07:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868791#M343216</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-04-09T17:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868794#M343217</link>
      <description>&lt;P&gt;I'm working on a sdtmig dataset, I have the Age variable;&lt;/P&gt;&lt;P&gt;I'm supposed to generate age_group;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;lt;65&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;=65&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;75&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;=75&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and then generate the count and percent of the age_group using proc freq.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It is a case study.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2023 18:16:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868794#M343217</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-04-09T18:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868795#M343218</link>
      <description>&lt;P&gt;Thank you very much sir, I will the proc format.&lt;/P&gt;&lt;P&gt;This is a brief on what I'm trying to achieve;&lt;/P&gt;&lt;P&gt;I'm working on a sdtmig dataset, I have the Age variable;&lt;/P&gt;&lt;P&gt;I'm supposed to generate age_group;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;lt;65&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;=65&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;75&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;=75&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and then generate the count and percent using proc freq.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2023 18:18:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868795#M343218</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-04-09T18:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868796#M343219</link>
      <description>&lt;P&gt;Ok sir. Thank you.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2023 18:21:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868796#M343219</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-04-09T18:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868797#M343220</link>
      <description>&lt;P&gt;Hi, I actually added a length statement before running the code.&lt;/P&gt;&lt;P&gt;"&amp;lt;65"&lt;/P&gt;&lt;P&gt;"&amp;gt;=65"&lt;/P&gt;&lt;P&gt;"&amp;lt;75"&lt;/P&gt;&lt;P&gt;"&amp;gt;=75"&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this possible to group like that at all?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2023 18:42:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868797#M343220</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-04-09T18:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868800#M343221</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440493"&gt;@PrinceAde&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm working on a sdtmig dataset, I have the Age variable;&lt;/P&gt;
&lt;P&gt;I'm supposed to generate age_group;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;lt;65&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;=65&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;75&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;=75&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and then generate the count and percent of the age_group using proc freq.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440493"&gt;@PrinceAde&lt;/a&gt;&amp;nbsp;Thank you but this does not explain what you want. If a person is 63 years old, should this person be in both the &amp;lt;65 and &amp;lt;75 group? 63 is &amp;lt;65 and 63 is also &amp;lt;75. That's what it sounds like you are asking for. Please explain and clear this up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whatever it is you want, use FORMATs.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2023 20:48:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868800#M343221</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-09T20:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868812#M343225</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440493"&gt;@PrinceAde&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm working on a sdtmig dataset, I have the Age variable;&lt;/P&gt;
&lt;P&gt;I'm supposed to generate age_group;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;lt;65&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;=65&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;75&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;=75&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and then generate the count and percent of the age_group using proc freq.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It is a case study.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If, as in &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;'s example a person that is of age 63 is supposed to be counted in both the &amp;lt;65 and the &amp;lt;75 age groups you have a very limited choice. Proc freq will not do this with a single variable. In fact the only approach that I think is reasonable would not use such a value at all as the tools reside in special places of format definition and 4 procedures that can use them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of the reasons we so often ask for example data and the result of your process for that given data is that it does not require pulling one fact at a time.&lt;/P&gt;
&lt;P&gt;Here is a small enough example data set that you should be able to count categories you want. SHOW us the result using this data set that you would want from Proc Freq. Don't write any code to assign values. Manually count and show us the result of how many are in each category. Or just list which category belongs next to each value.&lt;/P&gt;
&lt;PRE&gt;data example;
   input age;
datalines;
55
57
63
64
64
64
65
66
67
67
68
68
69
70
71
71
71
72
72
73
74
75 
76
76
77
77
78
;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2023 23:00:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868812#M343225</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-04-09T23:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868819#M343231</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;65 : 55 57 63 64 64. i.e &amp;lt;65 should appear 5 times in the column&lt;/P&gt;&lt;P&gt;&amp;gt;=65 : 65 66 67 67 68 68 68 69 70 71 71 71 71&amp;nbsp; 72 72 73 74 76 76 77 77 78.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;gt;=65 should appear 22 times&lt;/P&gt;&lt;P&gt;&amp;lt;75 : 55 57 63 64 64 64 65 66 67 67 68 68 69 70 71 71 71 72 72 73 74.&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;75 should appear 21 times&lt;/P&gt;&lt;P&gt;&amp;gt;=75 :&amp;nbsp; 75 76 76 77 77 78&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;gt;=75 should appear 6 times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is what I expect for each category if that is possible at all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 05:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868819#M343231</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-04-10T05:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868833#M343235</link>
      <description>&lt;P&gt;Thank you for clearing this up.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes it is possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will need to run PROC FREQ twice, once using a format that assigns people to the categories &amp;lt;65 and &amp;gt;=65, and once using a format that assigns people to the categories &amp;lt;75 and &amp;gt;=75.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value one low-&amp;lt;65='&amp;lt;65' 65-high='&amp;gt;=65';
    value two low-&amp;lt;75='&amp;lt;75' 75-high='&amp;gt;=75';
run;
proc freq data=have;
    tables age;
    format age one.;
run;
proc freq data=have;
    tables age;
    format age two.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Apr 2023 11:32:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868833#M343235</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-10T11:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868884#M343248</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440493"&gt;@PrinceAde&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;65 : 55 57 63 64 64. i.e &amp;lt;65 should appear 5 times in the column&lt;/P&gt;
&lt;P&gt;&amp;gt;=65 : 65 66 67 67 68 68 68 69 70 71 71 71 71&amp;nbsp; 72 72 73 74 76 76 77 77 78.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;gt;=65 should appear 22 times&lt;/P&gt;
&lt;P&gt;&amp;lt;75 : 55 57 63 64 64 64 65 66 67 67 68 68 69 70 71 71 71 72 72 73 74.&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;75 should appear 21 times&lt;/P&gt;
&lt;P&gt;&amp;gt;=75 :&amp;nbsp; 75 76 76 77 77 78&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;gt;=75 should appear 6 times.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is what I expect for each category if that is possible at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is possible for limited operations with a custom format defined as MULTILABEL. One thing about such formats is that only Procs Tabulate, Report, Means and Summary (currently) honor them.&lt;/P&gt;
&lt;PRE&gt;data example;
   input age;
datalines;
55
57
63
64
64
64
65
66
67
67
68
68
69
70
71
71
71
72
72
73
74
75 
76
76
77
77
78
;


Proc format;
value myagegroups (multilabel)
low -&amp;lt; 65 = '&amp;lt;65'
65  - high = '&amp;gt;=65'
low -&amp;lt; 75 = '&amp;lt;75'
75  - high = '&amp;gt;=75'
;
run;

proc tabulate data=example;
   class age /mlf ;
   format age myagegroups.;
   table age,
         n
   ;
run;&lt;/PRE&gt;
&lt;P&gt;Which results in&lt;/P&gt;
&lt;PRE&gt;     n&lt;BR /&gt;age 6 
&amp;lt;65  
&amp;lt;75  21 
&amp;gt;=65 21 
&amp;gt;=75 6 
&lt;/PRE&gt;
&lt;P&gt;If actual order of output is critical I leave as an exercise to an interested reader to experiment with the Proc Format options Notsorted, the order of the assignment statements in the format values and the ORDER= options in Proc Tabulate as they interact.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the MLF option on the Class statement tells SAS to expect a MULTILABEL defined format and use the feature if actually defined in the format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Again, those 4 procedures are the only ones that will do what you are wanting with a single variable and single pass through the data.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 15:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/868884#M343248</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-04-10T15:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/869104#M343315</link>
      <description>&lt;P&gt;I did as you said using if else condition to create a new variable agegroup;&lt;/P&gt;&lt;P&gt;&amp;lt;65&lt;/P&gt;&lt;P&gt;&amp;gt;=65&lt;/P&gt;&lt;P&gt;as agroupx then proc freq&lt;/P&gt;&lt;P&gt;&amp;lt;75&lt;/P&gt;&lt;P&gt;&amp;gt;=75&amp;nbsp;&lt;/P&gt;&lt;P&gt;as agegroupy then proc freq.&lt;/P&gt;&lt;P&gt;Thank you very much. Very helpful.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 13:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/869104#M343315</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-04-11T13:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/869105#M343316</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440493"&gt;@PrinceAde&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I did as you said using if else condition to create a new variable agegroup;&lt;/P&gt;
&lt;P&gt;&amp;lt;65&lt;/P&gt;
&lt;P&gt;&amp;gt;=65&lt;/P&gt;
&lt;P&gt;as agroupx then proc freq&lt;/P&gt;
&lt;P&gt;&amp;lt;75&lt;/P&gt;
&lt;P&gt;&amp;gt;=75&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as agegroupy then proc freq.&lt;/P&gt;
&lt;P&gt;Thank you very much. Very helpful.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But I did not say to create new variables. I specifically said use formats. Part of the purpose of having these discussions is not just to provide an answer, but to point you in the direction of better methods. Formats are better for a lot of reasons than creating new variables, and apparently despite formats being mentioned by many people, you chose not to use this better method.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 13:08:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/869105#M343316</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-11T13:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/869106#M343317</link>
      <description>&lt;P&gt;Thank you very much sir. I was able to resolve. I did proc freq for &amp;lt;65 and &amp;gt;=65 and another one for &amp;lt;75 and &amp;gt;=75.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 13:05:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/869106#M343317</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-04-11T13:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/869110#M343319</link>
      <description>&lt;P&gt;Yes, I initially used proc format, however I&amp;nbsp; realized that I still needed to generate proc means for the initial age variable, hence the reason I created the agegroup variable to be able to generate the proc frequencies&amp;nbsp; separately.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 13:40:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/869110#M343319</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-04-11T13:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: Age grouping</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/869113#M343320</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440493"&gt;@PrinceAde&lt;/a&gt;&amp;nbsp;formats work in PROC MEANS and most data analysis PROCs&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 13:58:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Age-grouping/m-p/869113#M343320</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-11T13:58:54Z</dc:date>
    </item>
  </channel>
</rss>

