<?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 How to Proc Tabulate By group? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Proc-Tabulate-By-group/m-p/390050#M25209</link>
    <description>&lt;P&gt;This is working code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Crosstab: main_job and work_inj_descript_code_sec2_ */
PROC TABULATE
DATA=WORK.DATA_JOINED6;

CLASS main_job / ORDER=UNFORMATTED;
CLASS work_inj_descript_code_sec2_ / ORDER=UNFORMATTED;
/*BY work_related_fulln;*/
TABLE /* Row Dimension */
work_inj_descript_code_sec2_,
/* Column Dimension */
main_job*
ColPctN;
;
FORMAT
main_job main_job.
work_inj_descript_code_sec2_ work_inj_descript_code_sec2_.;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;By I have a categorical variable (some_var) which has value of =1 and =2, I would like the above code to execute one for some_var=1 and another for some_var=2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Crosstab: main_job and work_inj_descript_code_sec2_ */
PROC TABULATE
DATA=WORK.DATA_JOINED6;

CLASS main_job / ORDER=UNFORMATTED;
CLASS work_inj_descript_code_sec2_ / ORDER=UNFORMATTED;
/*BY work_related_fulln;*/
TABLE /* Row Dimension */
work_inj_descript_code_sec2_,
/* Column Dimension */
main_job*
ColPctN;
;
FORMAT
main_job main_job.
work_inj_descript_code_sec2_ work_inj_descript_code_sec2_.;
BY some_var;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I get the following error -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: Data set WORK.DATA_JOINED6 is not sorted in ascending sequence. The current BY group has Are you here today for an illness
or injury related to your work? = 2 and the next BY group has Are you here today for an illness or injury related to your w
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 17 observations read from the data set WORK.DATA_JOINED6.
NOTE: PROCEDURE TABULATE used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;-------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Update&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried this, and it seems to be working&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SORT DATA=WORK.DATA_JOINED6 OUT=WORK.DATA_JOINED7;
	by work_related_fulln; 

PROC TABULATE
DATA=WORK.DATA_JOINED7;
	
	CLASS main_job /	ORDER=UNFORMATTED;
	CLASS work_inj_descript_code_sec2_ /	ORDER=UNFORMATTED;
	/*BY work_related_fulln;*/
	TABLE /* Row Dimension */
		work_inj_descript_code_sec2_,
		/* Column Dimension */
		main_job*
  		ColPctN;
	;
  	FORMAT
    	main_job main_job.
		work_inj_descript_code_sec2_ work_inj_descript_code_sec2_.;

	By work_related_fulln;

RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But in the log statement, it gave me this warning:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WARNING: A class, frequency, or weight variable is missing on every observation.
NOTE: The above message was for the following BY group:
      Are you here today for an illness or injury related to your work?=R
WARNING: A class, frequency, or weight variable is missing on every observation.
NOTE: The above message was for the following BY group:
      Are you here today for an illness or injury related to your work?=-99&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is this a warning I can overlook, do should I fix anything?&lt;/P&gt;</description>
    <pubDate>Wed, 23 Aug 2017 14:46:26 GMT</pubDate>
    <dc:creator>KubiK888</dc:creator>
    <dc:date>2017-08-23T14:46:26Z</dc:date>
    <item>
      <title>How to Proc Tabulate By group?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Proc-Tabulate-By-group/m-p/390050#M25209</link>
      <description>&lt;P&gt;This is working code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Crosstab: main_job and work_inj_descript_code_sec2_ */
PROC TABULATE
DATA=WORK.DATA_JOINED6;

CLASS main_job / ORDER=UNFORMATTED;
CLASS work_inj_descript_code_sec2_ / ORDER=UNFORMATTED;
/*BY work_related_fulln;*/
TABLE /* Row Dimension */
work_inj_descript_code_sec2_,
/* Column Dimension */
main_job*
ColPctN;
;
FORMAT
main_job main_job.
work_inj_descript_code_sec2_ work_inj_descript_code_sec2_.;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;By I have a categorical variable (some_var) which has value of =1 and =2, I would like the above code to execute one for some_var=1 and another for some_var=2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Crosstab: main_job and work_inj_descript_code_sec2_ */
PROC TABULATE
DATA=WORK.DATA_JOINED6;

CLASS main_job / ORDER=UNFORMATTED;
CLASS work_inj_descript_code_sec2_ / ORDER=UNFORMATTED;
/*BY work_related_fulln;*/
TABLE /* Row Dimension */
work_inj_descript_code_sec2_,
/* Column Dimension */
main_job*
ColPctN;
;
FORMAT
main_job main_job.
work_inj_descript_code_sec2_ work_inj_descript_code_sec2_.;
BY some_var;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I get the following error -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: Data set WORK.DATA_JOINED6 is not sorted in ascending sequence. The current BY group has Are you here today for an illness
or injury related to your work? = 2 and the next BY group has Are you here today for an illness or injury related to your w
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 17 observations read from the data set WORK.DATA_JOINED6.
NOTE: PROCEDURE TABULATE used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;-------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Update&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried this, and it seems to be working&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SORT DATA=WORK.DATA_JOINED6 OUT=WORK.DATA_JOINED7;
	by work_related_fulln; 

PROC TABULATE
DATA=WORK.DATA_JOINED7;
	
	CLASS main_job /	ORDER=UNFORMATTED;
	CLASS work_inj_descript_code_sec2_ /	ORDER=UNFORMATTED;
	/*BY work_related_fulln;*/
	TABLE /* Row Dimension */
		work_inj_descript_code_sec2_,
		/* Column Dimension */
		main_job*
  		ColPctN;
	;
  	FORMAT
    	main_job main_job.
		work_inj_descript_code_sec2_ work_inj_descript_code_sec2_.;

	By work_related_fulln;

RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But in the log statement, it gave me this warning:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WARNING: A class, frequency, or weight variable is missing on every observation.
NOTE: The above message was for the following BY group:
      Are you here today for an illness or injury related to your work?=R
WARNING: A class, frequency, or weight variable is missing on every observation.
NOTE: The above message was for the following BY group:
      Are you here today for an illness or injury related to your work?=-99&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is this a warning I can overlook, do should I fix anything?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 14:46:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Proc-Tabulate-By-group/m-p/390050#M25209</guid>
      <dc:creator>KubiK888</dc:creator>
      <dc:date>2017-08-23T14:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to Proc Tabulate By group?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Proc-Tabulate-By-group/m-p/390055#M25210</link>
      <description>&lt;P&gt;For BY to work you need to sort your data according to the same order you list your variables in the BY statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So use PROC SORT before the PROC TABULATE to order your data and then use your code. I would also move the BY statement to right after the PROC statement. It's common convention and then a person can tell quickly if the procedure uses a BY statement or not.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 22:36:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Proc-Tabulate-By-group/m-p/390055#M25210</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-22T22:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to Proc Tabulate By group?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Proc-Tabulate-By-group/m-p/390059#M25211</link>
      <description>&lt;P&gt;Try this modification:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;PROC TABULATE
   DATA=WORK.DATA_JOINED6;

   CLASS main_job / ORDER=UNFORMATTED;
   CLASS work_inj_descript_code_sec2_ / ORDER=UNFORMATTED;
   Class some_var;
   TABLE /* PAGE DIMENSION*/
         Some_var,
         /* Row Dimension */
         work_inj_descript_code_sec2_,
         /* Column Dimension */
         main_job*ColPctN;
   ;
   FORMAT
      main_job main_job.
      work_inj_descript_code_sec2_ work_inj_descript_code_sec2_.
      /* add any format for some_var if available*/
   ;

RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On this forum in helps to post code or log results into a code box opened with the menu icon {i}&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 23:16:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Proc-Tabulate-By-group/m-p/390059#M25211</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-08-22T23:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to Proc Tabulate By group?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Proc-Tabulate-By-group/m-p/390277#M25231</link>
      <description>&lt;P&gt;I have tried your suggestion and it seems to work, but I get this warning "WARNING: A class, frequency, or weight variable is missing on every observation." Any thoughts?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 14:47:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Proc-Tabulate-By-group/m-p/390277#M25231</guid>
      <dc:creator>KubiK888</dc:creator>
      <dc:date>2017-08-23T14:47:14Z</dc:date>
    </item>
  </channel>
</rss>

