<?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: Using proc freq for a crosstab (two-by-two); how do I include all levels of Y? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/377030#M65429</link>
    <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;- at least I don't feel &lt;U&gt;quite&lt;/U&gt; so dumb.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what I'm looking for at the minimum:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10391iC20D2BA628DF6C81/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="occ.PNG" title="occ.PNG" /&gt;&lt;/P&gt;&lt;P&gt;If the output dataset ends up including percent, col, and row, etc., that's cool. I have&amp;nbsp;a second .xls&amp;nbsp;with&amp;nbsp;formulas reading in&amp;nbsp;the values in the num_events column, ordered by region, summarizing 2 decades' worth of this monthly data&amp;nbsp;by year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reason, when I use list and sparse like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data = have;
	where provider_type in ('Illegally-Operating');
		table region * num_events / list
			out = want sparse;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is my&amp;nbsp;output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10393i6C31396B1589DA46/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="occ2.PNG" title="occ2.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What gives? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Keri&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jul 2017 14:44:54 GMT</pubDate>
    <dc:creator>kjowers</dc:creator>
    <dc:date>2017-07-18T14:44:54Z</dc:date>
    <item>
      <title>Using proc freq for a crosstab (two-by-two); how do I include all levels of Y?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/376772#M65401</link>
      <description>&lt;P&gt;I feel like this should be really easy and obvious, but I can't figure it out. Any advice is appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It starts with just a simple crosstab. I need the output to be a list of values of x (number of events) for each level of y (regions), of which there are 13. There are 4 types of events, and I need a table to summarize each. Occasionally, there are 0 events in a region. However, I need the output to list all 13 regions. Is there some ridiculously simple solution that I've just overlooked? I tried the sparse option, and it didn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data = have noprint;
    table region * num_events / nopercent norow nocol
    out = want;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you!!!!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 21:48:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/376772#M65401</guid>
      <dc:creator>kjowers</dc:creator>
      <dc:date>2017-07-17T21:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc freq for a crosstab (two-by-two); how do I include all levels of Y?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/376791#M65405</link>
      <description>&lt;P&gt;Can you at least show what the result is expected to look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It actually is not "ridiculously easy" easy to display values that do not appear in your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on what I wanted for appearance I would likely create a custom format to display your region values and then use one of the procedures that can use Preloadfmt option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you are creating an output data set you could use the SPARSE option if you also use the LIST option on the tables statement.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 22:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/376791#M65405</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-07-17T22:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc freq for a crosstab (two-by-two); how do I include all levels of Y?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/376849#M65417</link>
      <description>&lt;P&gt;Does NUM_EVENTS really represent the type of event? &amp;nbsp;If not, then what is the right variable name?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whatever the proper name, it's easier to add the missing categories in later. &amp;nbsp;I can't test this right now, but it should create a shell with all the categories:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table shell as&lt;/P&gt;
&lt;P&gt;select distinct a.region, distinct b.num_events from have a, have b;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My SQL isn't super strong, but that should work. &amp;nbsp;Then merge it back in with the PROC FREQ results:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=shell;&lt;/P&gt;
&lt;P&gt;by region num_events;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;data really_want;&lt;/P&gt;
&lt;P&gt;merge want (in=in1) shell;&lt;/P&gt;
&lt;P&gt;by region num_events;&lt;/P&gt;
&lt;P&gt;if in1=0 then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;count=0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;percent=0;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 02:31:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/376849#M65417</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-18T02:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc freq for a crosstab (two-by-two); how do I include all levels of Y?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/376989#M65427</link>
      <description>&lt;P&gt;Better post some sample data to explain your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1)try SPARSE option&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token statement"&gt;table&lt;/SPAN&gt; region &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; num_events &lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;/CODE&gt;sparse ;&lt;/PRE&gt;
&lt;P&gt;2) try ZERO option&lt;/P&gt;
&lt;P&gt;weight count/zero ;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 13:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/376989#M65427</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-07-18T13:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc freq for a crosstab (two-by-two); how do I include all levels of Y?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/377030#M65429</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;- at least I don't feel &lt;U&gt;quite&lt;/U&gt; so dumb.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's what I'm looking for at the minimum:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10391iC20D2BA628DF6C81/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="occ.PNG" title="occ.PNG" /&gt;&lt;/P&gt;&lt;P&gt;If the output dataset ends up including percent, col, and row, etc., that's cool. I have&amp;nbsp;a second .xls&amp;nbsp;with&amp;nbsp;formulas reading in&amp;nbsp;the values in the num_events column, ordered by region, summarizing 2 decades' worth of this monthly data&amp;nbsp;by year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reason, when I use list and sparse like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data = have;
	where provider_type in ('Illegally-Operating');
		table region * num_events / list
			out = want sparse;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is my&amp;nbsp;output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10393i6C31396B1589DA46/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="occ2.PNG" title="occ2.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What gives? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Keri&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 14:44:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/377030#M65429</guid>
      <dc:creator>kjowers</dc:creator>
      <dc:date>2017-07-18T14:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc freq for a crosstab (two-by-two); how do I include all levels of Y?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/377034#M65430</link>
      <description>&lt;P&gt;Computers are dumb. If it's not in the data at all, how is SAS supposed to know it even exists? Obviously you need to tell it in some manner, and the way to specify that is using a FORMAT or a CLASS data set with ALL the levels/combinations needed. If you search PRELOADFMT and PROC TABULATE you'll see many ways of getting this done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings11/087-2011.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings11/087-2011.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings11/239-2011.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings11/239-2011.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Proc-Tabulate-creating-a-row-of-zeros-for-nonexistent-variable/m-p/331286/highlight/true#M74437" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Proc-Tabulate-creating-a-row-of-zeros-for-nonexistent-variable/m-p/331286/highlight/true#M74437&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 14:52:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/377034#M65430</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-18T14:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc freq for a crosstab (two-by-two); how do I include all levels of Y?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/377054#M65432</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a sample of my data. There are other variables, but I don't use them here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10398iAB266068D2D5AE93/image-size/small?v=1.0&amp;amp;px=-1" border="0" alt="occ5.PNG" title="occ5.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data = have;&lt;BR /&gt;     where type in ('illegal');
	table region * num_events_1 / sparse
	out = want1;
run; 

proc export data = want
	outfile = '\want.xls'
	dbms = excel replace;
	sheet = 'want1';
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;this is my output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/10399iC3644A9F79330A85/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="occ6.PNG" title="occ6.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only problem is that the values in 'count' are for the entire 'have' dataset, not just the type = 'illegal'&amp;nbsp;subset. Any idea why? I'm not familiar with how 'sparse' works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 15:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/377054#M65432</guid>
      <dc:creator>kjowers</dc:creator>
      <dc:date>2017-07-18T15:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc freq for a crosstab (two-by-two); how do I include all levels of Y?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/377055#M65433</link>
      <description>&lt;P&gt;Please post your code AND data as text, otherwise you're asking us to type out your data and code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are instructions here on how to include your data as a data step so it can be used immediately in SAS&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2017 15:42:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/377055#M65433</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-18T15:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc freq for a crosstab (two-by-two); how do I include all levels of Y?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/378239#M65498</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;! Will do! That makes total sense, and I can see how that could be a royal pain. I'll attach my&amp;nbsp;syntax and data as files to a previous reply - I'm having a hard time getting the syntax you linked to to work for me (it's definitely me, not the syntax). It looks really cool and helpful, so&amp;nbsp;I'll definitely take more time later to try to figure out how it's working. Thanks again!!!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 16:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/378239#M65498</guid>
      <dc:creator>kjowers</dc:creator>
      <dc:date>2017-07-21T16:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc freq for a crosstab (two-by-two); how do I include all levels of Y?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/378247#M65499</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached are my data and syntax files.&amp;nbsp;I've also pasted the syntax below. The issue is that I need the&amp;nbsp;last 2 sheets on the exported .xls file to list all 13 regions, with 0 values as appropriate, rather than excluding the regions with 0 values. I can't seem to get the list/sparse combo to work - it outputs the total sample, not the subsetted samples.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*** import current month's data ***/

proc import out = have_master
	datafile = 'W:\Have\have.xls' 
	dbms = excel replace;
	getnames = yes;
run;


/*** assign region ***/

data have_1;
	set have_master;

	format region 2.;
	informat region 2.;

	if county in (2)			then region = 1;
	if county in (30)			then region = 2;
	if county in (3)			then region = 3;
	if county in (16)			then region = 4;
	if county in (15)			then region = 5;
	if county in (13)			then region = 6;
	if county in (1,11,21)		then region = 7;
	if county in (5,9,14,17,20)	then region = 8;
	if county in (19,22,23)		then region = 9;
	if county in (4,8,18)		then region = 10;
	if county in (7,12)			then region = 11;
	if county in (10)			then region = 12;
	if county in (6)			then region = 13;

run;


/*** create output datasets ***/

	/** subset variables **/

data have_2;
	set have_1;

	format lh 1.;
	format lc 1.;
	format ulh 1.;
	format ulc 1.;

	if type in ('registered')	then lh = 1;
	if type in ('licensed')		then lc = 1;
	if type in ('illegal') and illegal_type in ('h')
								then ulh = 1;
	if type in ('illegal') and illegal_type in ('c')
								then ulc = 1;

run;

	/** tables **/

proc freq data = have_2;
	where type in ('registered');
		tables lh * region / nopercent norow nocol
			out = lh;
run;

proc freq data = have_2;
	where type in ('licensed');
		tables lc * region / nopercent norow nocol
			out = lc;
run;

proc freq data = have_2;
	where type in ('illegal') and illegal_type in ('h');
		tables ulh * region / nopercent norow nocol
			out = ulh;
run;

proc freq data = have_2;
	where type in ('illegal') and illegal_type in ('c');
		table ulc * region / nopercent norow nocol
			out = ulc;
run;


/*** export output to .xls ***/

proc export data = lh
	outfile = 'W:\Have\want.xls'
	dbms = excel replace;
	sheet = 'lh';

proc export data = lc
	outfile = 'W:\Have\want.xls'
	dbms = excel replace;
	sheet = 'lc';

proc export data = ulh
	outfile = 'W:\Have\want.xls'
	dbms = excel replace;
	sheet = 'ulh';

proc export data = ulc
	outfile = 'W:\Have\want.xls'
	dbms = excel replace;
	sheet = 'ulc';

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!!!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 16:55:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/378247#M65499</guid>
      <dc:creator>kjowers</dc:creator>
      <dc:date>2017-07-21T16:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc freq for a crosstab (two-by-two); how do I include all levels of Y?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/378255#M65501</link>
      <description>&lt;P&gt;SPARSE/LIST will not work in this case. You need to use PRELOADFMT or CLASSDATA instead.&lt;/P&gt;
&lt;P&gt;If the data is not there, SAS cannot know it exists unless you tell it somehow. That 'somehow' is PRELOADFMT or CLASSDATA.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A quick search of those terms on here or lexjansen.com will illustrate fully worked examples that will show you how to modify your code/process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132722"&gt;@kjowers&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Attached are my data and syntax files.&amp;nbsp;I've also pasted the syntax below. The issue is that I need the&amp;nbsp;last 2 sheets on the exported .xls file to list all 13 regions, with 0 values as appropriate, rather than excluding the regions with 0 values. I can't seem to get the list/sparse combo to work - it outputs the total sample, not the subsetted samples.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*** import current month's data ***/

proc import out = have_master
	datafile = 'W:\Have\have.xls' 
	dbms = excel replace;
	getnames = yes;
run;


/*** assign region ***/

data have_1;
	set have_master;

	format region 2.;
	informat region 2.;

	if county in (2)			then region = 1;
	if county in (30)			then region = 2;
	if county in (3)			then region = 3;
	if county in (16)			then region = 4;
	if county in (15)			then region = 5;
	if county in (13)			then region = 6;
	if county in (1,11,21)		then region = 7;
	if county in (5,9,14,17,20)	then region = 8;
	if county in (19,22,23)		then region = 9;
	if county in (4,8,18)		then region = 10;
	if county in (7,12)			then region = 11;
	if county in (10)			then region = 12;
	if county in (6)			then region = 13;

run;


/*** create output datasets ***/

	/** subset variables **/

data have_2;
	set have_1;

	format lh 1.;
	format lc 1.;
	format ulh 1.;
	format ulc 1.;

	if type in ('registered')	then lh = 1;
	if type in ('licensed')		then lc = 1;
	if type in ('illegal') and illegal_type in ('h')
								then ulh = 1;
	if type in ('illegal') and illegal_type in ('c')
								then ulc = 1;

run;

	/** tables **/

proc freq data = have_2;
	where type in ('registered');
		tables lh * region / nopercent norow nocol
			out = lh;
run;

proc freq data = have_2;
	where type in ('licensed');
		tables lc * region / nopercent norow nocol
			out = lc;
run;

proc freq data = have_2;
	where type in ('illegal') and illegal_type in ('h');
		tables ulh * region / nopercent norow nocol
			out = ulh;
run;

proc freq data = have_2;
	where type in ('illegal') and illegal_type in ('c');
		table ulc * region / nopercent norow nocol
			out = ulc;
run;


/*** export output to .xls ***/

proc export data = lh
	outfile = 'W:\Have\want.xls'
	dbms = excel replace;
	sheet = 'lh';

proc export data = lc
	outfile = 'W:\Have\want.xls'
	dbms = excel replace;
	sheet = 'lc';

proc export data = ulh
	outfile = 'W:\Have\want.xls'
	dbms = excel replace;
	sheet = 'ulh';

proc export data = ulc
	outfile = 'W:\Have\want.xls'
	dbms = excel replace;
	sheet = 'ulc';

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!!!!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 17:20:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/378255#M65501</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-21T17:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc freq for a crosstab (two-by-two); how do I include all levels of Y?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/378261#M65503</link>
      <description>&lt;P&gt;Awesome! Thank you so much!!! I really appreciate your help!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 17:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-proc-freq-for-a-crosstab-two-by-two-how-do-I-include-all/m-p/378261#M65503</guid>
      <dc:creator>kjowers</dc:creator>
      <dc:date>2017-07-21T17:42:07Z</dc:date>
    </item>
  </channel>
</rss>

