<?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: Help with creating a single table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/help-creating-single-table/m-p/789828#M252819</link>
    <description>&lt;P&gt;Please don't type plain text in a code box, this means to read your text we have to constantly scroll to the right.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would appreciate it if you could re-format everything so the text is readable without constantly scrolling to the right.&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jan 2022 21:38:42 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-01-12T21:38:42Z</dc:date>
    <item>
      <title>help creating single table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-creating-single-table/m-p/789830#M252794</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use the below proc sql to create a data set. The varibale "WorkType" contains three options: 'Contact Maint', 'Contact New', and 'Agency Maint'. How do I create a single table providing a count of each of the WorkTypes? I want to send as a summary table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql; 
create table CPIM_Automation as 
SELECT DISTINCT
CPC.CHNL_PTNR_CASE_ID AS TrackingRecord
,CPT2.CHNL_PTNR_CASE_TYP_DE AS WorkType
,CPT1.CHNL_PTNR_CASE_TYP_DE AS SubType
,CPC.CHNL_PTNR_CASE_STAT_CD AS CaseStatusCode
,CPCS.SRC_SYS_CD AS SourceCode
,CPC.CHNL_PTNR_CASE_BGN_DT AS CaseStartDate
,AGET.CHNL_PTNR_CASE_SBJ_VAL_ID AS AgentType
,AGEY.CHNL_PTNR_CASE_SBJ_VAL_ID AS AgencyType
,CPCS.CHNL_PTNR_CASE_STEP_NB AS StepNumber

FROM 
CPM1P1.CHNL_PTNR_CASE_STEP CPCS
LEFT JOIN CPM1P1.CHNL_PTNR_CASE CPC ON CPCS.CHNL_PTNR_CASE_ID = CPC.CHNL_PTNR_CASE_ID
LEFT JOIN CPM1P1.CHNL_PTNR_CASE_TYP CPT1 ON CPC.CHNL_PTNR_CASE_TYP_CD = CPT1.CHNL_PTNR_CASE_TYP_CD
LEFT JOIN CPM1P1.CHNL_PTNR_CASE_TYP CPT2 ON CPT1.PRNT_CHNL_PTNR_CASE_TYP_CD = CPT2.CHNL_PTNR_CASE_TYP_CD 

       
LEFT JOIN (SELECT DISTINCT
          SUB2.CHNL_PTNR_CASE_ID, SUB2.CHNL_PTNR_CASE_SBJ_VAL_ID
          FROM CPM1P1.CHNL_PTNR_CASE_SBJ SUB2
          WHERE SUB2.CHNL_PTNR_CASE_SBJ_TYP_CD = 'CONTACTAGENTTYPE') AGET
          ON CPCS.CHNL_PTNR_CASE_ID = AGET.CHNL_PTNR_CASE_ID 

LEFT JOIN (SELECT DISTINCT
          SUB3.CHNL_PTNR_CASE_ID, SUB3.CHNL_PTNR_CASE_SBJ_VAL_ID
          FROM CPM1P1.CHNL_PTNR_CASE_SBJ SUB3
          WHERE SUB3.CHNL_PTNR_CASE_SBJ_TYP_CD = 'AGENCYTYPE') AGEY
          ON CPCS.CHNL_PTNR_CASE_ID = AGEY.CHNL_PTNR_CASE_ID
WHERE 
CaseStartDate between (intnx('month', today(), -1, 'b')+19) and (intnx('month', today(), 0, 'b')+19)
/*CaseStartDate between '20Oct2021'd and '20Nov2021'd*/
and SourceCode = 'SSPortal'
and StepNumber = 1 

ORDER BY CPC.CHNL_PTNR_CASE_ID ASC
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jan 2022 21:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-creating-single-table/m-p/789830#M252794</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2022-01-12T21:46:00Z</dc:date>
    </item>
    <item>
      <title>Help with creating a single table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-creating-single-table/m-p/789827#M252818</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm using the proc sql code below (below Proc tabulate) to create a data set. In the varibale "WorkType" there are 3 options: "Contact Maint", "Contact New", and "Agency Maint".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to create a summary table that gives me a count of each WorkType.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I have tried the following proc tabulate and cannot get it. It's my first time creating a table from my data set and I need some help, Please Any suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
Title 1 'Singular Table';

proc tabulate data=CPIM_Automation;
Table WorkType;
Class 'Contact Maint' 'Contact New' 'Agency New';
run; 



proc sql; 
create table CPIM_Automation as 
SELECT DISTINCT
CPC.CHNL_PTNR_CASE_ID AS TrackingRecord
,CPT2.CHNL_PTNR_CASE_TYP_DE AS WorkType
,CPT1.CHNL_PTNR_CASE_TYP_DE AS SubType
,CPC.CHNL_PTNR_CASE_STAT_CD AS CaseStatusCode
,CPCS.SRC_SYS_CD AS SourceCode
,CPC.CHNL_PTNR_CASE_BGN_DT AS CaseStartDate
,AGET.CHNL_PTNR_CASE_SBJ_VAL_ID AS AgentType
,AGEY.CHNL_PTNR_CASE_SBJ_VAL_ID AS AgencyType
,CPCS.CHNL_PTNR_CASE_STEP_NB AS StepNumber

FROM 
CPM1P1.CHNL_PTNR_CASE_STEP CPCS
LEFT JOIN CPM1P1.CHNL_PTNR_CASE CPC ON CPCS.CHNL_PTNR_CASE_ID = CPC.CHNL_PTNR_CASE_ID
LEFT JOIN CPM1P1.CHNL_PTNR_CASE_TYP CPT1 ON CPC.CHNL_PTNR_CASE_TYP_CD = CPT1.CHNL_PTNR_CASE_TYP_CD
LEFT JOIN CPM1P1.CHNL_PTNR_CASE_TYP CPT2 ON CPT1.PRNT_CHNL_PTNR_CASE_TYP_CD = CPT2.CHNL_PTNR_CASE_TYP_CD 
       
LEFT JOIN (SELECT DISTINCT
          SUB2.CHNL_PTNR_CASE_ID, SUB2.CHNL_PTNR_CASE_SBJ_VAL_ID
          FROM CPM1P1.CHNL_PTNR_CASE_SBJ SUB2
          WHERE SUB2.CHNL_PTNR_CASE_SBJ_TYP_CD = 'CONTACTAGENTTYPE') AGET
          ON CPCS.CHNL_PTNR_CASE_ID = AGET.CHNL_PTNR_CASE_ID 

LEFT JOIN (SELECT DISTINCT
          SUB3.CHNL_PTNR_CASE_ID, SUB3.CHNL_PTNR_CASE_SBJ_VAL_ID
          FROM CPM1P1.CHNL_PTNR_CASE_SBJ SUB3
          WHERE SUB3.CHNL_PTNR_CASE_SBJ_TYP_CD = 'AGENCYTYPE') AGEY
          ON CPCS.CHNL_PTNR_CASE_ID = AGEY.CHNL_PTNR_CASE_ID
WHERE 
CaseStartDate between (intnx('month', today(), -1, 'b')+19) and (intnx('month', today(), 0, 'b')+19)
/*CaseStartDate between '20Oct2021'd and '20Nov2021'd*/
and SourceCode = 'SSPortal'
and StepNumber = 1 

ORDER BY CPC.CHNL_PTNR_CASE_ID ASC
;
quit;

data CPIM_Automation;
set CPIM_Automation;
if AgencyType='' and AgentType^='' then AgencyAgentType = AgentType;
if AgencyType^='' and AgentType='' then AgencyAgentType = AgencyType;
if AgencyType='' and AgentType='' then AgencyAgentType = 'Missing';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 22:27:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-creating-single-table/m-p/789827#M252818</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2022-01-12T22:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help with creating a single table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-creating-single-table/m-p/789828#M252819</link>
      <description>&lt;P&gt;Please don't type plain text in a code box, this means to read your text we have to constantly scroll to the right.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would appreciate it if you could re-format everything so the text is readable without constantly scrolling to the right.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 21:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-creating-single-table/m-p/789828#M252819</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-12T21:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: help creating single table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-creating-single-table/m-p/789834#M252797</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393528"&gt;@LMSSAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use the below proc sql to create a data set. The varibale "WorkType" contains three options: 'Contact Maint', 'Contact New', and 'Agency Maint'. How do I create a single table providing a count of each of the WorkTypes? I want to send as a summary table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=CPIM_Automation ;
    tables worktype/out=_counts_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 22:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-creating-single-table/m-p/789834#M252797</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-12T22:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: help creating single table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-creating-single-table/m-p/789837#M252798</link>
      <description>Thank you!! That works</description>
      <pubDate>Wed, 12 Jan 2022 22:08:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-creating-single-table/m-p/789837#M252798</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2022-01-12T22:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help with creating a single table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-creating-single-table/m-p/789845#M252820</link>
      <description>&lt;P&gt;You should arrange your code in logical order. Your have the PROC TABUlATE at the top, but the code to create the data set below which doesn't really make sense. Note that I edited your post to make it legible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you just want PROC FREQ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=CPIM_Automation;
table workType AgencyAgentType;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, you should look into the COALESCEC()/COALESCE() functions - they're quite useful - would replace that last three IF statements into one.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data CPIM_Automation;
set CPIM_Automation;
AgencyAgentType = coalescec(AgentType, AgencyType, "Missing");
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/393528"&gt;@LMSSAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm using the proc sql code below (below Proc tabulate) to create a data set. In the varibale "WorkType" there are 3 options: "Contact Maint", "Contact New", and "Agency Maint".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to create a summary table that gives me a count of each WorkType.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I have tried the following proc tabulate and cannot get it. It's my first time creating a table from my data set and I need some help, Please Any suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;Title 1 'Singular Table';&lt;BR /&gt;proc tabulate data=CPIM_Automation;&lt;BR /&gt;Table WorkType;&lt;BR /&gt;Class 'Contact Maint' 'Contact New' 'Agency New';&lt;BR /&gt;run; &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;proc sql; 
create table CPIM_Automation as 
SELECT DISTINCT
CPC.CHNL_PTNR_CASE_ID AS TrackingRecord
,CPT2.CHNL_PTNR_CASE_TYP_DE AS WorkType
,CPT1.CHNL_PTNR_CASE_TYP_DE AS SubType
,CPC.CHNL_PTNR_CASE_STAT_CD AS CaseStatusCode
,CPCS.SRC_SYS_CD AS SourceCode
,CPC.CHNL_PTNR_CASE_BGN_DT AS CaseStartDate
,AGET.CHNL_PTNR_CASE_SBJ_VAL_ID AS AgentType
,AGEY.CHNL_PTNR_CASE_SBJ_VAL_ID AS AgencyType
,CPCS.CHNL_PTNR_CASE_STEP_NB AS StepNumber

FROM 
CPM1P1.CHNL_PTNR_CASE_STEP CPCS
LEFT JOIN CPM1P1.CHNL_PTNR_CASE CPC ON CPCS.CHNL_PTNR_CASE_ID = CPC.CHNL_PTNR_CASE_ID
LEFT JOIN CPM1P1.CHNL_PTNR_CASE_TYP CPT1 ON CPC.CHNL_PTNR_CASE_TYP_CD = CPT1.CHNL_PTNR_CASE_TYP_CD
LEFT JOIN CPM1P1.CHNL_PTNR_CASE_TYP CPT2 ON CPT1.PRNT_CHNL_PTNR_CASE_TYP_CD = CPT2.CHNL_PTNR_CASE_TYP_CD 
       
LEFT JOIN (SELECT DISTINCT
          SUB2.CHNL_PTNR_CASE_ID, SUB2.CHNL_PTNR_CASE_SBJ_VAL_ID
          FROM CPM1P1.CHNL_PTNR_CASE_SBJ SUB2
          WHERE SUB2.CHNL_PTNR_CASE_SBJ_TYP_CD = 'CONTACTAGENTTYPE') AGET
          ON CPCS.CHNL_PTNR_CASE_ID = AGET.CHNL_PTNR_CASE_ID 

LEFT JOIN (SELECT DISTINCT
          SUB3.CHNL_PTNR_CASE_ID, SUB3.CHNL_PTNR_CASE_SBJ_VAL_ID
          FROM CPM1P1.CHNL_PTNR_CASE_SBJ SUB3
          WHERE SUB3.CHNL_PTNR_CASE_SBJ_TYP_CD = 'AGENCYTYPE') AGEY
          ON CPCS.CHNL_PTNR_CASE_ID = AGEY.CHNL_PTNR_CASE_ID
WHERE 
CaseStartDate between (intnx('month', today(), -1, 'b')+19) and (intnx('month', today(), 0, 'b')+19)
/*CaseStartDate between '20Oct2021'd and '20Nov2021'd*/
and SourceCode = 'SSPortal'
and StepNumber = 1 

ORDER BY CPC.CHNL_PTNR_CASE_ID ASC
;
quit;

data CPIM_Automation;
set CPIM_Automation;
if AgencyType='' and AgentType^='' then AgencyAgentType = AgentType;
if AgencyType^='' and AgentType='' then AgencyAgentType = AgencyType;
if AgencyType='' and AgentType='' then AgencyAgentType = 'Missing';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 22:27:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-creating-single-table/m-p/789845#M252820</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-12T22:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Help with creating a single table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/help-creating-single-table/m-p/789977#M252885</link>
      <description>Thank you, very helpfil</description>
      <pubDate>Thu, 13 Jan 2022 12:56:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/help-creating-single-table/m-p/789977#M252885</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2022-01-13T12:56:01Z</dc:date>
    </item>
  </channel>
</rss>

