<?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: manipulations with proc freq in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/741772#M29153</link>
    <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;, thank you! Not quite sure what the issue was but it looks like adding the order=internal statement fixed it and is now displaying what I expected.&lt;BR /&gt;</description>
    <pubDate>Sun, 16 May 2021 19:08:34 GMT</pubDate>
    <dc:creator>Merdock</dc:creator>
    <dc:date>2021-05-16T19:08:34Z</dc:date>
    <item>
      <title>manipulations with proc freq</title>
      <link>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/739133#M28931</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following dataset and I was wondering what would be the shortest, most elegant way to get an output similar to the one in screenshot attached? I'm thinking I can probably get it done the hard way by manipulating a bunch of proc freq statements but was hoping someone has suggestions for a more efficient/shorter way to obtain such a table? Total eligible column contains the number of participants in study=A, whereas Total Enrolled refers to number of participants in study=B. Basically, the idea behind this table is that I want to see, across the 2 age groups, how many of the participants from study A also enrolled in study B.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 479px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59040i789CCCF8EF5B760D/image-dimensions/479x131?v=v2" width="479" height="131" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;data have;
input patid $ site $ agegrp study $;
datalines;
1001 site1  1 A
1002 site1  1 A
1003 site1  2 A
1004 site1  2 A
1005 site1  2 A
1006 site1  2 A
1006 site1  2 B
2001 site2  1 A
2002 site2  1 A
2003 site2  1 A
2004 site2  1 A
2005 site2  1 A
2005 site2  1 B
2006 site2  1 A
2007 site2  1 A
2008 site2  1 A
2008 site2  1 B
2009 site2  1 A
2009 site2  1 B
2010 site2  2 A
2010 site2  2 B
2011 site2  2 A
2011 site2  2 B
2012 site2  2 A
2012 site2  2 B
2013 site2  2 A
2013 site2  2 B
2014 site2  2 A
2014 site2  2 B
2015 site2  2 A
2015 site2  2 B
2016 site2  2 A
3001 site3  1 A
3002 site3  1 A
3002 site3  1 B
3003 site3  1 A
3003 site3  1 B
3004 site3  2 A
3005 site3  2 A
; 
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 04:19:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/739133#M28931</guid>
      <dc:creator>Merdock</dc:creator>
      <dc:date>2021-05-05T04:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: manipulations with proc freq</title>
      <link>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/739144#M28932</link>
      <description>&lt;P&gt;Maybe with proc tabulate, but you won't get count and percentage in one cell.&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 06:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/739144#M28932</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-05-05T06:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: manipulations with proc freq</title>
      <link>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/739146#M28933</link>
      <description>&lt;P&gt;Look at this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data int; /* make numeric variables for summing */
set have;
eligible = (study = "A");
enrolled = (study = "B");
run;

proc summary data=int; /* summarize */
var enrolled eligible;
class site agegrp;
output
  out=want1 (where=(_type_ in (2,3)))
  sum()=
;
run;

data want2; /* create "total" values */
set want1;
if _type_ = 2 then agegrp = 99;
run;

proc format; /* nice text for across variable */
value agegrp
  1 = "Age Group 1"
  2 = "Age Group 2"
  99 = "Total"
;
run;

proc report data=want2;
column site agegrp,(eligible enrolled percent);
define site /group;
define agegrp / "Age Group" across format=agegrp.;
define eligible / "Total Eligible N" analysis sum;
define enrolled / "Total Enrolled N" analysis sum;
define percent / "Enrolled Percent" computed format=percent7.2;
compute percent;
  _c4_ = _c3_ / _c2_;
  _c7_ = _c6_ / _c5_;
  _c10_ = _c9_ / _c8_;
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 May 2021 06:34:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/739146#M28933</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-05T06:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: manipulations with proc freq</title>
      <link>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/739220#M28934</link>
      <description>&lt;P&gt;See this as a starting point.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: Do you want the must compact code or do you want code that will be easy to modify/update as needed? There's often a big trade off there.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 14:10:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/739220#M28934</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-05T14:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: manipulations with proc freq</title>
      <link>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/740369#M29050</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;, thank you so much, this works perfectly. I do have one small question though: I noticed that if I try to change the value of age group in proc format so that instead of "Age Group 1" and "Age Group 2" I have "10-&amp;lt;25 years" and "25-&amp;lt;40 years", the final table (want2) won't display the age group columns in chronological order anymore, i.e. "10-&amp;lt;25 years" first and then "25-&amp;lt;40 years". Instead, I get the "25-&amp;lt;40 years" column first. How can I change this so that the first group displayed is the "10-&amp;lt;25 years" one?&lt;BR /&gt;&lt;BR /&gt;Thanks again!</description>
      <pubDate>Tue, 11 May 2021 04:33:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/740369#M29050</guid>
      <dc:creator>Merdock</dc:creator>
      <dc:date>2021-05-11T04:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: manipulations with proc freq</title>
      <link>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/740370#M29051</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, thank you for the link, very helpful! Ideally, I'd like to have a combination of both compact and easily updated to apply to other situations but I think that for this case, I'll settle for compactness.&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 04:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/740370#M29051</guid>
      <dc:creator>Merdock</dc:creator>
      <dc:date>2021-05-11T04:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: manipulations with proc freq</title>
      <link>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/741057#M29108</link>
      <description>&lt;P&gt;I can't repeat your behavior; could it be that the unformatted values are different in your real data than the ones you posted here?&lt;/P&gt;
&lt;P&gt;Anyway, use an ORDER= option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=want2;
column site agegrp,(eligible enrolled percent);
define site /group;
define agegrp / "Age Group" across format=agegrp. order=formatted;
define eligible / "Total Eligible N" analysis sum;
define enrolled / "Total Enrolled N" analysis sum;
define percent / "Enrolled Percent" computed format=percent7.2;
compute percent;
  _c4_ = _c3_ / _c2_;
  _c7_ = _c6_ / _c5_;
  _c10_ = _c9_ / _c8_;
endcomp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will work as long as the formatted values sort correctly in lexical order.&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 11:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/741057#M29108</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-13T11:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: manipulations with proc freq</title>
      <link>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/741772#M29153</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;, thank you! Not quite sure what the issue was but it looks like adding the order=internal statement fixed it and is now displaying what I expected.&lt;BR /&gt;</description>
      <pubDate>Sun, 16 May 2021 19:08:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/manipulations-with-proc-freq/m-p/741772#M29153</guid>
      <dc:creator>Merdock</dc:creator>
      <dc:date>2021-05-16T19:08:34Z</dc:date>
    </item>
  </channel>
</rss>

