<?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: PROC FREQ: Specify list of variables for multiway table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-Specify-list-of-variables-for-multiway-table/m-p/645775#M193073</link>
    <description>&lt;P&gt;You can use proc sql to get the list:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	select Name 
		into :list separated by '*'
		from sashelp.vcolumn
			where libname = 'WORK' 
				and memname = 'POISONCOMPARISON' 
				and lowcase(name) like 'proper^_ingredient%' escape '^'
	;
quit;

proc freq
      compress
      data= work.PoisonComparison
      order= freq;
    tables strPoisonTaken*&amp;amp;list. / list nocum missing;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In sashelp.vcolumn library-names and dataset-names are in upcase. In SQL the underscore is a wildcard for one char, so it should be escaped.&lt;/P&gt;</description>
    <pubDate>Thu, 07 May 2020 04:32:53 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2020-05-07T04:32:53Z</dc:date>
    <item>
      <title>PROC FREQ: Specify list of variables for multiway table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-Specify-list-of-variables-for-multiway-table/m-p/645760#M193065</link>
      <description>&lt;P&gt;I use PROC TRANSPOSE to transpose a data set (variable: Proper_ingredient). I never know what the resulting number of transposed columns from one run to the next will be (typically, though, 2-9).&lt;/P&gt;&lt;P&gt;When I want to get frequencies on the transposed columns, I know I can do this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FREQ
    COMPRESS
    DATA=WORK.PoisonComparison
    ORDER=FREQ;
    TABLES strPoisonTaken Proper_ingredient: /NOCUM MISSING;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;That will give me all the oneway tables needed.&lt;/P&gt;&lt;P&gt;But what if I want a multiway table:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FREQ
    COMPRESS
    DATA=WORK.PoisonComparison
    ORDER=FREQ;
    TABLES strPoisonTaken*Proper_ingredient1*Proper_ingredient2*...*Proper_ingredientx /LIST NOCUM MISSING;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there a simple way to instruct SAS to create that listing?&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2020 02:11:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-Specify-list-of-variables-for-multiway-table/m-p/645760#M193065</guid>
      <dc:creator>JacquesR</dc:creator>
      <dc:date>2020-05-07T02:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ: Specify list of variables for multiway table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-Specify-list-of-variables-for-multiway-table/m-p/645774#M193072</link>
      <description>&lt;P&gt;You can build a macrovar of the form proper_ingredient1*proper_ingredient2*…. using the dictionary.columns table in sql (untested below):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
   select distinct name into :varlist separated by '*'
   from dictionary.columns
   where libname ='WORK' and upcase(memname)='POISONCOMPARISON'
    and upcase(name) like 'PROPER^_INGREDIENT%' escape '^' ;
quit;
proc freq compress data=work.poisoncomparison order=freq;
  tables strpoisontaken*&amp;amp;varlist / list nocum missing;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt; , I've corrected the above to account for the "_" wild character.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2020 04:39:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-Specify-list-of-variables-for-multiway-table/m-p/645774#M193072</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-05-07T04:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ: Specify list of variables for multiway table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-Specify-list-of-variables-for-multiway-table/m-p/645775#M193073</link>
      <description>&lt;P&gt;You can use proc sql to get the list:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	select Name 
		into :list separated by '*'
		from sashelp.vcolumn
			where libname = 'WORK' 
				and memname = 'POISONCOMPARISON' 
				and lowcase(name) like 'proper^_ingredient%' escape '^'
	;
quit;

proc freq
      compress
      data= work.PoisonComparison
      order= freq;
    tables strPoisonTaken*&amp;amp;list. / list nocum missing;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In sashelp.vcolumn library-names and dataset-names are in upcase. In SQL the underscore is a wildcard for one char, so it should be escaped.&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2020 04:32:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FREQ-Specify-list-of-variables-for-multiway-table/m-p/645775#M193073</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-05-07T04:32:53Z</dc:date>
    </item>
  </channel>
</rss>

