<?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 merger proc freq on multiple columns of a table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862810#M340812</link>
    <description>&lt;P&gt;Transpose the data first.&amp;nbsp; Then you can run your PROC FREQ on the transposed data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To use PROC TRANSPOSE you will need to variable (or set of variables) you can use to uniquely identify the rows with a BY statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=asamtable_2 out=TALL ;
   by ID ;
   var rectype Delay_Rsn ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise use a data step to do the transpose (which could be a VIEW if you want);&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TALL ;
  set asamtable_2'
  length _name_ $32 col1 $100 ;
  _name_='rectype';col1=rectype; output;
  _name_='delay_rsn';col1=Delay_Rsn; output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you can make a WHERE statement that tests both variables&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=TALL;
	tables _name_*col1 / list ;
where (_name_='rectype' and col1 not in ("Brief Initial Screen" 
			      "Followup Assessment" 
			      "Initial Assessment"
      ))
   or (_name_='delay_rsn' and col1 not in (
                 "Waiting for level of care availability"
                 "Waiting for language-specific services"
				 "Waiting for other special popn-specific svcs"
				 "Hospitalized"
				 "Incarcerated"
				 "Patient preference"
				 "Waiting for ADA accommodation"
				 "Other"
       ))
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 07 Mar 2023 21:15:30 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-03-07T21:15:30Z</dc:date>
    <item>
      <title>How to merger proc freq on multiple columns of a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862765#M340792</link>
      <description>&lt;P&gt;The codes below are to run two separate proc freq on two columns of the same table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc freq data=asamtable_2;
	tables rectype /nocum nopercent;
	where rectype not in ("Brief Initial Screen" 
			      "Followup Assessment" 
			      "Initial Assessment");&lt;/PRE&gt;&lt;PRE&gt;proc freq data=asamtable_2;
	tables Delay_Rsn /nocum nopercent;
	where Delay_Rsn not in (&lt;BR /&gt;                                 "Waiting for level of care availability"
                                 "Waiting for language-specific services"
				 "Waiting for other special popn-specific svcs"
				 "Hospitalized"
				 "Incarcerated"
				 "Patient preference"
				 "Waiting for ADA accommodation"
				 "Other");
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I get this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ralizadeh_0-1678215831225.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81170iF52BC342246D6C09/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ralizadeh_0-1678215831225.png" alt="ralizadeh_0-1678215831225.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Question is: What would be the best way to merge these two separate codes into one code (basically run one code on TWO columns) in SAS Studio to get the same result? How would you do it in SAS EG?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 19:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862765#M340792</guid>
      <dc:creator>ralizadeh</dc:creator>
      <dc:date>2023-03-07T19:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to merger proc freq on multiple columns of a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862768#M340794</link>
      <description>&lt;P&gt;The WHERE statement subsets observations for the procedure. So you can't get what you want with a single Proc freq and WHERE statements because the counts would be wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please describe the concern about trying to run the results in "one code".&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 19:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862768#M340794</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-07T19:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to merger proc freq on multiple columns of a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862784#M340802</link>
      <description>&lt;P&gt;Looks like you did understand my "one code" comments. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;SPAN&gt;Yes, I wanted a single Proc freq and WHERE statements.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What are the alternatives if that can't be done this way? Are there any other proc steps I might use to obtain what I want?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 20:20:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862784#M340802</guid>
      <dc:creator>ralizadeh</dc:creator>
      <dc:date>2023-03-07T20:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to merger proc freq on multiple columns of a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862786#M340803</link>
      <description>&lt;P&gt;Do a single ODS table and then filter the results afterwards. &lt;STRONG&gt;This only works if you want counts, the percentages will not be correct.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Run frequency for tables;
ods table onewayfreqs=temp;
proc freq data=sashelp.class;
	table sex age;
run;

*Format output;
data want;
length variable $32. variable_value $50.;
set temp;
Variable=scan(table, 2);

Variable_Value=strip(trim(vvaluex(variable)));

keep variable variable_value frequency percent cum:;
label variable='Variable' 
	variable_value='Variable Value';
run;

*Display;
*Display;
proc print data=want label;
where (variable = 'Age' and variable_value not in ('10', '11', '13', '14')) | (variable = 'Sex' and variable_value not in ('M'));
var variable variable_value frequency;
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/440479"&gt;@ralizadeh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The codes below are to run two separate proc freq on two columns of the same table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc freq data=asamtable_2;
	tables rectype /nocum nopercent;
	where rectype not in ("Brief Initial Screen" 
			      "Followup Assessment" 
			      "Initial Assessment");&lt;/PRE&gt;
&lt;PRE&gt;proc freq data=asamtable_2;
	tables Delay_Rsn /nocum nopercent;
	where Delay_Rsn not in (&lt;BR /&gt;                                 "Waiting for level of care availability"
                                 "Waiting for language-specific services"
				 "Waiting for other special popn-specific svcs"
				 "Hospitalized"
				 "Incarcerated"
				 "Patient preference"
				 "Waiting for ADA accommodation"
				 "Other");
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I get this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ralizadeh_0-1678215831225.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81170iF52BC342246D6C09/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ralizadeh_0-1678215831225.png" alt="ralizadeh_0-1678215831225.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question is: What would be the best way to merge these two separate codes into one code (basically run one code on TWO columns) in SAS Studio to get the same result? How would you do it in SAS EG?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help would be appreciated.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 20:57:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862786#M340803</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-03-07T20:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to merger proc freq on multiple columns of a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862804#M340809</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 suggestion, however that wasn't what I was looking for. Despite the fact that your codes will merge two frequency tables into one, they still do not answer my question. In my code, there is a WHERE statement for each column, and they are distinct. I need a method that keeps the two conditions true for their respective columns.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 21:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862804#M340809</guid>
      <dc:creator>ralizadeh</dc:creator>
      <dc:date>2023-03-07T21:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to merger proc freq on multiple columns of a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862808#M340811</link>
      <description>See the edit, you can implement your WHERE on the final data set rather than on the PROC FREQ.</description>
      <pubDate>Tue, 07 Mar 2023 21:11:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862808#M340811</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-03-07T21:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to merger proc freq on multiple columns of a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862810#M340812</link>
      <description>&lt;P&gt;Transpose the data first.&amp;nbsp; Then you can run your PROC FREQ on the transposed data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To use PROC TRANSPOSE you will need to variable (or set of variables) you can use to uniquely identify the rows with a BY statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=asamtable_2 out=TALL ;
   by ID ;
   var rectype Delay_Rsn ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise use a data step to do the transpose (which could be a VIEW if you want);&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TALL ;
  set asamtable_2'
  length _name_ $32 col1 $100 ;
  _name_='rectype';col1=rectype; output;
  _name_='delay_rsn';col1=Delay_Rsn; output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you can make a WHERE statement that tests both variables&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=TALL;
	tables _name_*col1 / list ;
where (_name_='rectype' and col1 not in ("Brief Initial Screen" 
			      "Followup Assessment" 
			      "Initial Assessment"
      ))
   or (_name_='delay_rsn' and col1 not in (
                 "Waiting for level of care availability"
                 "Waiting for language-specific services"
				 "Waiting for other special popn-specific svcs"
				 "Hospitalized"
				 "Incarcerated"
				 "Patient preference"
				 "Waiting for ADA accommodation"
				 "Other"
       ))
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Mar 2023 21:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862810#M340812</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-07T21:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to merger proc freq on multiple columns of a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862816#M340815</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;! Very much appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 21:38:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862816#M340815</guid>
      <dc:creator>ralizadeh</dc:creator>
      <dc:date>2023-03-07T21:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to merger proc freq on multiple columns of a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862832#M340821</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/440479"&gt;@ralizadeh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Looks like you did understand my "one code" comments. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;SPAN&gt;Yes, I wanted a single Proc freq and WHERE statements.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are the alternatives if that can't be done this way? Are there any other proc steps I might use to obtain what I want?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Still haven't explained why the need, seems cumbersome.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a new data set, set the values you don't want to missing.&lt;/P&gt;
&lt;P&gt;Then call proc freq with the two variables but NO where statements.&lt;/P&gt;
&lt;P&gt;Counts and percents should match the desired result, there will be a count of missing displayed, which may be useful. Also you can use these variables in two-way (or more-way) tables.&lt;/P&gt;
&lt;P&gt;I think this may be a lot less wor&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 22:05:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merger-proc-freq-on-multiple-columns-of-a-table/m-p/862832#M340821</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-07T22:05:18Z</dc:date>
    </item>
  </channel>
</rss>

